html - placeholder div in IE not work (the cursor appears at the end) -


the cursor not @ beginning of div! appears @ end .. after text-placeholder!

in chrome, works perfect! cursor @ beginning of div, before text-placeholder, in ie cursor @ end ....

[contenteditable=true]:empty:before{   content: attr(placeholder);   display: block; /* firefox */ } 

example --> codepen

enter image description here

any solution?

you use js:

    var div=document.getelementbyid("div");      function clearplaceholder() {        if (div.innerhtml=="enter text here...") {          document.getelementbyid("div").innerhtml="";        }      }      function addplaceholder() {        if (div.innerhtml=="") {          document.getelementbyid("div").innerhtml="enter text here...";        }      }
    <div contenteditable="true" onfocus="clearplaceholder();" onfocusout="addplaceholder();" id="div">enter text here...</div>
works in ie , chrome... didn't test firefox or other browsers, should work on browsers js enabled.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -