最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - reset a form to the default values - Stack Overflow

programmeradmin3浏览0评论

Currently I have:

$("#your_email").val(this.defaultValue;)

I want to be cycling through all form elements and resetting them to their default value

Currently I have:

$("#your_email").val(this.defaultValue;)

I want to be cycling through all form elements and resetting them to their default value

Share Improve this question edited Aug 31, 2010 at 15:40 user113716 322k64 gold badges453 silver badges441 bronze badges asked Aug 31, 2010 at 15:01 kalpaitchkalpaitch 5,27110 gold badges45 silver badges69 bronze badges 4
  • 2 Do you have to use jQuery? Why not just use an input of type reset? It's meant to do exactly what you're trying to do. – Esteban Araya Commented Aug 31, 2010 at 15:08
  • 1 @Esteban: because jQuery is the answer to everything. – BalusC Commented Aug 31, 2010 at 15:17
  • 3 Doesn't seem to me that a jQuery solution was requested. this.defaultValue implies a native solution. – user113716 Commented Aug 31, 2010 at 15:41
  • 1 @BalusC - Tru dat. Seems SO isn't so much a technology q/a platform as a soapbox for jQuery evangelists. – Joel Etherton Commented Aug 31, 2010 at 18:09
Add a comment  | 

1 Answer 1

Reset to default 23

you don't need jQuery for this, just get the form dom element and call reset() on it.

Or, fetch with jQuery like:

$("#myFormId")[0].reset();
发布评论

评论列表(0)

  1. 暂无评论