如何使用Jquery按类选择CKEditor中的元素

use*_*507 4 ckeditor

我不知道如何使用jQuery选择器按类在CKEditor中选择元素,所以任何帮助都表示赞赏.

ole*_*leq 11

CKEDITOR.instances.editor1.window.getFrame().$检索编辑器可编辑区域的本机DOM元素.所以:

$( CKEDITOR.instances.editor1.window.getFrame().$ ).contents().find( anything );
Run Code Online (Sandbox Code Playgroud)

应该解决你的问题.


另请注意,CKEditor为DOM操作提供了一个API:

CKEDITOR.instances.editor1.document.getById( 'someId' );
CKEDITOR.instances.editor1.document.getElementsByTag( 'div' );
Run Code Online (Sandbox Code Playgroud)