[英]Span tag inside the div tag is not appearing
我必須在對話框窗口的onclick
事件的CKEditor中的div
標簽內創建一個span
。 我嘗試了以下代碼,但無法正常工作。
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 );
您已將本機DOM API與CKEditor的API完全混合在一起。 甚至很難猜測您在編寫該代碼時的想法,但是我希望這會對您有所幫助:
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 );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.