简体   繁体   中英

jquery editor on dom elements

I'm trying to use a wysiwyg editor to change content on newly created div elements.but i'm unable to do so. the editor only see pre existing elements in the html but not newly created ones. I'm using the following code to create new div element.

$("button").click(function() {
  var elm = $('<div id="text">testing testing</div>');
  elm.appendTo('#wrapper');

I'm using ckeditor to make the created div editable. This is by simply doing this

$('#text').ckeditor();

This is not working. Editor cannot see the newly created div. Regardless to what editor i use, this is always the case. What am i doing wrong. Any solution for this.

You need to attach editor after the element was created.

$("button").click(function() {
    var elm = $('<div id="text">testing testing</div>');
    elm.appendTo('#wrapper');
    elm.ckeditor();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM