How to Get Value from tinymce Editor using jQuery
In this blog, we will learn how to get value from tinymce editor using jquery selector, sometimes we need to get value from tinymce editor on button click on on any event , mostly we need value on 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 let’s see how to get value :
Example:
<textarea name="descr" id="textarea1" class="materialize-textarea">hello tinymce</textarea>
<button type="button" id="btn">get</button>
<script>
$(document).ready(function() {
$('#btn).click( function(){
$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.