开发者

access textarea value

开发者 https://www.devze.com 2023-01-01 17:01 出处:网络
I have aon 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(

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("");
0

精彩评论

暂无评论...
验证码 换一张
取 消