How to Get tinymce Editor Value Using Javascript
In this blog, we will learn how to get value from tinymce editor using javascript, sometimes we need to get value from tinymce editor on a button click on on any event, mostly we need a value on the event when we use ajax in our project.
To get value from tinymce editor is not easy as compared to other inputs but also it is not much difficult to let’s see how to get value :
Example:
<textarea name="descr" id="textarea1" class="materialize-textarea">hello tinymce</textarea>
<button type="button" onclick="getcontent()">get</button>
<script>
function getcontent()
{
var data;
data=tinyMCE.get("#textarea1").getContent();
console.log(data);
}
</script>
Note:
In the above example we have used tinyMce.get().getContent() function, so to use this function you should place this code after the tinmyce.js file otherwise this code would not work.