Search code examples
jquerywysihtml5

WYSIHTML5 textarea content is not getting cleared


I've a text area having id ="myTextArea", I'm able to fetch the content of text area but I'm not able to clear the content once user successfully submits the data. I'm using wysihtml5 plugin as my text editor. my code is as follows.

<textarea  name="def_text"  id="myTextArea" class="textarea"></textarea>

in my jquery file I'm doing as follows once user successfully submits the data.

$('#myTextArea').val('');

but it is not clearning the text area. I've tried $('#myTextArea').html('') too , but it is not working for me.


Solution

  • You can refer to this very good article : https://askgif.com/blog/142/how-to-get-wysihtml5-textarea-content-cleared/ (courtesy: https://askgif.com/)

    try using

    $('#myTextArea').data("wysihtml5").editor.clear();
    

    This worked fine for me.