Clear text area Clear text area jquery jquery

Clear text area


When you do $("#vinanghinguyen_images_bbocde").val('');, it removes all the content of the textarea, so if that's not what is happening, the problem is probably somewhere else.

It might help if you post a little bit larger portion of your code, since the example you provided works.


Use $('textarea').val('').

The problem with using $('textarea').text(''), or $('textarea').html('')for that matter is that it will only erase what was in the original DOM sent by the server. If a user clears it and then enters new input, the clear button will no longer work. Using .val('') handles the user input case properly.


This works:

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