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> © 2025 Manajmnt code Share to : ☷✎ Related How to create custom error page in bloggerIn this code i will be share with you how to create custom error page in blogger with background and… Read MoreHow to keep input value if user change current page in bloggerto keep value if user open other link in current page you must be use text area tag to do this, look… Read MoreHow to add related post to blogger without thumbnailsin this code I will be share with you how to add related post to blogger as list without thumbnails … Read More Comments
Comments
Post a Comment
message