I have to create a span
inside the div
tag in CKEditor on onclick
event of dialog window. I tried the following code but it is not working.
link = editor.document.createElement( 'div' );
this.commitContent( data );
link.setAttribute('itemscope','');
link.setAttribute( 'itemtype', 'http://schema.org/Person' );
link.setAttribute( 'id', 'person' );
link1 = editor.document.createElement( 'span' );
document.getElementById("person").appendChild(link1);
link1.setAttribute( 'itemprop', data.prop );
You completely mixed up native DOM API with CKEditor's API . It's even hard to guess what you had in mind writing that code, but I hope that this will help you a little:
var link = editor.document.createElement( 'div' );
this.commitContent( data );
link.setAttributes( {
itemscope: '',
itemtype: 'http://schema.org/Person',
id: 'person'
} );
// Now you need to append link somewhere...
editor.editable().append( link );
var link1 = editor.document.createElement( 'span' );
link1.appendTo( link );
link1.setAttribute( 'itemprop', data.prop );
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.