Slimen Tunis Slimen Tunis - 7 months ago 28
HTML Question

How to get the textarea value from jQuery LineControl Editor?

I'm using this jquery plugin to create a wysiwyg text editor,

I created a textarea where I want to display the text editor:


<textarea class="editor" rows="3" name="textEditor" id="textEditor"></textarea>


and then I called the jquery function:


<script type="text/javascript">
$(document).ready( function() {
$("#textEditor").Editor();
});
</script>


Until now everything is working good, but when I wanted to know if the text is writed correctly or not by using this function:

function displayText(){
alert($("#textEditor").val());
}


it gives me an empty text!

What am I missing ?

Answer

From the documentation of that plugin on Github, you need to use the getText option to retrieve the value of the editor. Try this:

function displayText(){
    alert($("#textEditor").Editor("getText"));
}