javascript - Focus a contenteditable div after double clicking on it -


i have div has contenteditable=false.

<div contenteditable="false" tabindex='1' style="width:100px;height:100px" id="my_div" >def text</div> 

i want make contenteditable=true and focus after double click.

function make_focus() { $("#my_div").prop('contenteditable','true');  $("#my_div").focus();    }  $(function() {      $("#my_div").dblclick(function(e)     {     make_focus();     })  }); 

if call make_focus() directly, without dblclick event this

<input type=button value='make focus' onclick="make_focus()"> 

then #my_div focused the way need. however, when check how works dblclick different result. first thing after double click text gets selected , i don't need it. second thing in ie div doesn't focused after double click. again, want double click work function called directly. here link jsfiddle shows how should work http://jsfiddle.net/ch3xs/14/ . , link shows how should not work(please, check in ie) http://jsfiddle.net/vr8yb/5/

p.s. following solution seems work:text selection in div(contenteditable) when double click

<div style="width:800px;height:100px" ondblclick="this.contenteditable=true;" onblur="this.contenteditable=false;this.classname='';" contenteditable="false">double click see</div> 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -