如何以编程方式重置窗体? [英] How to reset a form programmatically?
本文介绍了如何以编程方式重置窗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在一个JQuery点击事件函数中重置一个表单。如何做到这一点?
I want to reset a form in a JQuery click event function. How to do that ?
推荐答案
最简单: $(form-selector-here) [0] .reset()
,但也请参阅:使用jQuery重置多阶段表单
At it's simplest: $("form-selector-here")[0].reset()
but also see: Resetting a multi-stage form with jQuery
请注意,根本不需要jQuery,因为 $(选择器)[0]
获取原始DOM元素。您也可以说 document.getElementById(myFormId)。reset()
。
Note that jQuery isn't necessary for this at all, as $(selector)[0]
obtains the original DOM element. You could also say document.getElementById("myFormId").reset()
.
$("#btn1").click(function(){
$("#form1")[0].reset();
// OR
document.getElementById("form1").reset();
});
这篇关于如何以编程方式重置窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文