Twitch
Twitch

Reputation: 693

How to access elements by class with CKEditor 4?

I am building a plugin for CK-Editor and having trouble accessing span elements by their class name.

I've added the javascript commands to the plugin, but they aren't working. And when I try the same in the browser console, I get an empty array returned.

The span looks like the following:

<span class="rk_section" name="gXVyh" tags="test">UNITED STATES</span>

... and I've also tried the following directly in the browser console:

document.getElementsByClassName('rk_section')

CKEDITOR.document.find('.rk_section')

Both return empty arrays.

I'm baffled why this isn't working.

Upvotes: 0

Views: 1586

Answers (1)

Wizard
Wizard

Reputation: 3151

For a CKEditor instance named editor1:

CKEDITOR.instances.editor1.document.$.getElementsByClassName('rk_section')

Upvotes: 1

Related Questions