I have a on a for开发者_开发百科m of mine. I´m trying to reset the value (the value typed by the user) of this field on a certain event. However, I seem unable to access it both with .val() and .html().
Any advice on this?
Do not use .html()
, use .val()
.
$("#your_textarea_id").val("Some literal <textarea> content.");
This way special characters (<
, >
etc) will show up correctly.
Set an id on that field so you can easily target it with $('#the_id')
.
If it's a textarea use .text(''), input use .val('')
$('#text_area').val("");
精彩评论