access textarea value

时光总嘲笑我的痴心妄想 提交于 2019-12-02 17:07:42

问题


I have a on a form 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?


回答1:


Do not use .html(), use .val().

$("#your_textarea_id").val("Some literal <textarea> content.");

This way special characters (<, > etc) will show up correctly.




回答2:


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('')




回答3:


$('#text_area').val("");


来源:https://stackoverflow.com/questions/2956220/access-textarea-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!