With TinyMCE, I can easily manipulate content and send it back to the editor, like this:
// get content from tinyMCE
var content = tinyMCE.get('content').getContent();
// manipulate content using js replace
content = content.replace(/<\/?div>/gi, '');
// send back to tinyMCE
tinyMCE.get('content').setContent( content );
The above code works fine. However, I can't get this to work:
// get content from tinyMCE (it provides an html string)
var content = tinyMCE.get('content').getContent();
// make it into a jQuery object
var $content = $(content);
// manipulate the jquery object using jquery
$content = $content.remove('a');
// use a chained function to get its outerHTML
content = $("<div />").append( $content.clone() ).html();
// send back to tinyMCE
tinyMCE.get('content').setContent( content );
Is there something wrong with my methodology?