user271507
user271507

Reputation: 1259

How to select element inside CKEditor by class using Jquery

I cannot find out how to select element inside CKEditor by class using jQuery selector, so any help is appreciated.

Upvotes: 5

Views: 7733

Answers (3)

Pavel Černý
Pavel Černý

Reputation: 491

If you using jQuery Adapter (tested on 4.4.3 version)

$( $('.your_selector').ckeditor().editor.window.getFrame().$).contents().find('a.super_link')

Upvotes: 0

Konservin
Konservin

Reputation: 1017

This one worked for me:

$(youreditor.document.find('anything'))

where youreditor is

youreditor = CKEDITOR.replace( '' ... etc

Upvotes: 0

oleq
oleq

Reputation: 15895

CKEDITOR.instances.editor1.window.getFrame().$ retrieves a native DOM element for editor editable area. So:

$( CKEDITOR.instances.editor1.window.getFrame().$ ).contents().find( anything );

Should solve your problem.


Also note that CKEditor provides an API for DOM manipulation:

CKEDITOR.instances.editor1.document.getById( 'someId' );
CKEDITOR.instances.editor1.document.getElementsByTag( 'div' );

Upvotes: 12

Related Questions