Vali Shah
Vali Shah

Reputation: 1246

Content is not including in contentEditable Element

Hi I would like to create a contentEditable tag in my page all i want is whatever the text i'm typing after i created this element should go into that tag but it's not happening like that. can someone help me out ?

var pElement = document.createElement('p');
$(pElement).attr('contenteditable','true')
           .addClass('current');
$(getPElement).append(pElement);
$(getPElement).find('p.current').focus();

Upvotes: 0

Views: 61

Answers (1)

Simone
Simone

Reputation: 21262

If you want to create a contenteditable element with jQuery, you can do it like this (jsFiddle):

$("<div>").attr('contenteditable', 'true').html("edit me!").appendTo('body')

Upvotes: 1

Related Questions