For instance consider the following string:
<div><span class="author-advanced">hello <b>everyone</b></span></div>
It should print:
hello everyone
I'm using HTML5 editor. I've saved this string in mysql db and after retrieving it, I want to append it to text editor while keeping all formatting. What function/approach should be adopted to fix this?
If you are using <textarea>
you need to put the HTML
code inside the tag before initializing the editor. (in this case the <textarea>
is converted to an <iframe>
, that's the behavior of WYSIWYG editors using <textarea>
)
<textarea class="editor"><span class="author-advanced">hello <b>everyone</b></span></textarea>
If the editor doesn't use a <textarea>
then it use contenteditable="true"
attribute to display formatted HTML.
<div class="editor" contenteditable="true"><span class="author-advanced">hello <b>everyone</b></span></div>
Suppose HTML5Editor() is a function to initialize the editor:
$('.editor').HTML5Editor();
The HTML code must be inside the element before initializing the editor.