Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting HTML value from Tinymce

Is there a way to get HTML contents from TinyMCE editor using jQuery so I can copy this over to another div?

I tried several methods like val() on content but it doesn't seem to be working...

like image 674
John Kim Avatar asked Dec 20 '22 20:12

John Kim


2 Answers

if you are initilizing with jquery adaptor

 $(selector).tinyMCE().getContent();
like image 175
charlietfl Avatar answered Dec 23 '22 11:12

charlietfl


Using jQuery:

<textarea id="content" name="content">
$('#content').html()

Using TinyMce API:

$('#content').tinymce().activeEditor.getContent() // overall html
$('#content').tinymce().activeEditor.getContent({format : 'text'}) // overall text
$('#content').tinymce().selection.getContent() // selected html
$('#content').tinymce().selection.getContent({format : 'text'})) // selected text
like image 32
odiszapc Avatar answered Dec 23 '22 11:12

odiszapc