I would like to add some text when div is empty, I tried adding placeholder to the div, but it is not replacing the text when new text is being added.
HTML text:
<div contenteditable="true" placeholder="{enter text here}"/>
</div>
div:empty:before {
content:attr(placeholder);
color:gray
}
Also tried using js to replace the text on click but not working as expected.
below is the javascript code:
function selectText( containerid ) {
var node = document.getElementById( containerid );
if ( window.getSelection ) {
var range = document.createRange();
range.selectNodeContents( node );
window.getSelection().addRange( range );
}
}