I am trying to use the getContent feature of the Tinymce editor in WordPress admin area but to no avail.
Here is a working pen of what I want to do
https://codepen.io/anon/pen/oWxjyM?editors=1111
HTML
<textarea class="wp-editor-area" rows="20" autocomplete="off" cols="40" name="wprss_ftp_post_prepend" id="wprsspostprepend"><p>To give is good</p></textarea>
JS
jQuery(document).ready(function() {
$("#wprsspostprepend").addClass("prepend_editor");
var name = "wprsspostprepend";
if($("#" + name).length > 0) {
tinyMCE.init({
mode : "specific_textareas",
editor_selector : "prepend_editor"
});
var content = tinyMCE.activeEditor.getContent();
alert(content);
tinyMCE.activeEditor.setContent("<div id='random-wrap'>" + content + "</div>");
}
});
Why am I getting the null reference error in Wordpress if it works in codepen.