How to get WYSIHTML5 textarea content cleared?
💻 coding

How to get WYSIHTML5 textarea content cleared?

1 min read 98 words
1 min read
ShareWhatsAppPost on X
  • 1The user is unable to clear the content of a WYSIHTML5 textarea after submission.
  • 2Using $('#myTextArea').val(''); does not clear the textarea content.
  • 3The correct method to clear the content is $('#myTextArea').data('wysihtml5').editor.clear();.

AI-generated summary · May not capture all nuances

Key Insight
AskGif

"The user is unable to clear the content of a WYSIHTML5 textarea after submission."

How to get WYSIHTML5 textarea content cleared?

I have got 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 the user successfully submits the data. I'm using a 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 the user successfully submits the data.

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

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

Solution:

Try using the following line that worked for me.

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

Enjoyed this article?

Share it with someone who'd find it useful.

ShareWhatsAppPost on X

AskGif

Published on 18 October 2018 · 1 min read · 98 words

Part of AskGif Blog · coding

You might also like

How to get WYSIHTML5 textarea content cleared? | AskGif Blog