Search code examples
tinymce

how to get id of a node in TinyMCE?


I want to get the id of a node inside TinyMCE.

I searched in the documentation, but could not find this.

How can this be done?


Solution

  • First, it is important which node you want to get the id from. If you want to get the if of the parent node of your selection in TinyMCE use

    tinymce.activeEditor.selection.getNode().id;
    

    EDIT: In case you have a single node in your editor you can access this node id using

    tinymce.activeEditor.getBody().firstChild.id;