[英]Trying to clear form when submit button is clicked
I am trying to clear my form when the submit button is clicked. 单击提交按钮时,我试图清除表单。 It opens a page in a new window, and the value typed in the input field is still showing.
它会在新窗口中打开一个页面,并且仍会显示在输入字段中键入的值。
function clearform (formid){
$('#'+formid).reset()
}
And the HTML: 和HTML:
<form id="email-subscribe" action="http://feedburner.google.com/fb/a/mailverify?uri=MYURI&loc=en_US" method="post" target="_blank">
<input id="email" name="email" type="text" tabindex="1" placeholder="Enter your email" />
<button type="submit" onClick="clearform('email-subscribe');" >Submit</button>
</form>
What am I missing? 我想念什么?
reset()
is a method on the DOM element, not a jQuery method. reset()
是DOM元素上的方法,而不是jQuery方法。
document.getElementById(formid).reset();
or 要么
$('#formid')[0].reset();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.