How to add placeholder to div element using JavaScript <div > <div id="ph" contenteditable="true" style="color: #34acd0;border:1px solid #34acd0;padding: 3px;width: 50%;border-radius: 4px;" onkeyup="plho();plho2()" onclick="plho()" ><style>div#ph:before {content: 'search...';color: #34acd0;}</style></div> </div> <script> function plho(){ var ph1=document.getElementById("ph").innerHTML; if(ph1 === "<style>div#ph:before {content: 'search...';color: #34acd0;}</style>"){ document.getElementById("ph").innerHTML=""; } } function plho2(){ var ph1=document.getElementById("ph").innerHTML; if(ph1 === ""){ document.getElementById("ph").innerHTML="<style>div#ph:before {content: 'search...';color: #34acd0;}</style>"; } } </script> © Manajmnt code Share to : ☷✎ Comments
Comments
Post a Comment
message