JavaScript Answers

How to Get the Entered Value From a TinyMCE Text Area?

Spread the love

To get the entered value from a TinyMCE text area, we can use the tinyMCE.activeEditor.getContent() method.

For instance, if we have the following HTML:

<script src="" referrerpolicy="origin"></script>

<form method="post">
  <textarea id="mytextarea">Hello, World!</textarea>

to add the TinyMCE script and text area, then we can get the value when the editor is initialized by writing:

  selector: '#mytextarea',
  setup(editor) {
    editor.on('init', () => {

We call tinymce.init to create the text editor.

selector is the textarea element that we want to convert to a TinyMCE editor.

Then we have the setup method that calls editor.on with 'init' to watch when the editor is initialized.

Then callback will run when it’s initialized, so we can get the input value of the editor when the editor is initialized with tinyMCE.activeEditor.getContent() .

Therefore, we should see '<p>Hello, World!</p>’ logged.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.