admin管理员组文章数量:1393409
As you might guess I'm building a small chat system, and I would like that when the user clicks enter the message would be sent and the text area cleared.
I'm using this jquery:
jQuery('#my-form')[0].reset();
and it reloads the page which looks really noob.
any ideas?
As you might guess I'm building a small chat system, and I would like that when the user clicks enter the message would be sent and the text area cleared.
I'm using this jquery:
jQuery('#my-form')[0].reset();
and it reloads the page which looks really noob.
any ideas?
Share Improve this question asked Nov 30, 2011 at 22:43 coisocoiso 7,47912 gold badges47 silver badges63 bronze badges2 Answers
Reset to default 4$('#textbox1').val('');
Should clear a textbox
Assuming that your text-input/textarea is properly within a form, why not use:
<input type="reset" value="Clear the box" />
JS Fiddle demo.
Or:
<button type="reset">clear the text</button>
JS Fiddle demo.
本文标签: javascriptreset form element without reloading pageStack Overflow
版权声明:本文标题:javascript - reset form element without reloading page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744765114a2623992.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论