Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make div editable which is created dynamically

I want to make div editable which is created dynamically. Which is also draggable div .

This is what I tried

1)$("#divid").attr('contentEditable','true');

2)$("#divid").live("click",function(){
     $(this).click('contentEditable',true);
  });

3)$("#divid").click('contentEditable',true);

but none of the above working. Any idea how to make it working!

Thanks in advance!

like image 947
sandip Avatar asked Feb 18 '23 23:02

sandip


1 Answers

Since you are having a dynamically created div use .on() handler for it and .prop():

  $(document).on("click", "#divid", function(){
     $(this).prop('contentEditable',true);
  });

find out in fiddle: http://jsfiddle.net/SEvDe/

like image 170
Jai Avatar answered Feb 21 '23 02:02

Jai