Snippets

How to get content of Tinymce textarea via JS

Hi,

If you want to get content of Tinymce WYSIWYG editor via JavaScript or VueJS, this is the snippet that you can use.

// Get the HTML contents of the currently active editor
tinyMCE.activeEditor.getContent();

// Get the raw contents of the currently active editor
tinyMCE.activeEditor.getContent({format : 'raw'});

// Get content of a specific editor:
tinyMCE.get('contentId').getContent()

Here, contentId is the element ID that you want to grab. For example-

<textarea id="contentId" ....></textarea>

Hope it will work for you.

Thanks