I have create a rich text editor using DIV as editor container. How can I pass the DIV value to textarea? I already use jquery code. it success when I view it live but when I submit the form, the textarea value is empty. Here is my code:-
HTML
<div id="rte" contenteditable="true" unselectable="off">
</div>
<textarea name='rteHide' id='stage'></textarea>
JQuery
$(function() {
$("#rte").keyup(function() {
var content = $('#rte').html();
$("#stage").text(content);
});
});
I’m using this for wordpress plugin. Please let me know if there any other way to pass DIV value without using .post() jquery. Or using textarea as rich text editor container.
I required to create this editor instead using the current existing rich editor because we want to do enhancement in future.
Thanks in advance.
Try to use
val()
instead oftext()
to set the value of yourtextarea
Also, to make sure that there’s no conflict happen here, you can wrap your code inside: