属性'提交'对象#< HTMLFormElement>不是一个功能 [英] Property 'submit' of object #<HTMLFormElement> is not a function
本文介绍了属性'提交'对象#< HTMLFormElement>不是一个功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< form class =formid =form action =/ mailer.phpmethod =post>
我使用的jquery代码是这样的。
$('#form')。submit();
解决方案
检查表单以查看是否存在 HTMLInputElement
的id或name是 submit
。
一个属性提交
到 HTMLFormElement
,所以 submit
函数
示例:
< form class =formid =formaction =/ mailer.phpmethod =post>
< input type =buttonname =submitvalue =go/>
< / form>
js:
console.log($(#form)[0] .submit); //将是按钮元素,而不是提交函数。
jQuery的 .submit()
方法将会调用原始dom元素上的 .submit()
,所以会发生错误。
Can anyone explain to me what this error means? I would appreciate it a lot for any kindof help with this.
<form class="form" id="form" action="/mailer.php" method="post">
The Jquery code I'm using for it is this.
$('#form').submit();
解决方案
Check the form to see whether there is a HTMLInputElement
with id or name is submit
.
This will set a property submit
to the HTMLFormElement
, so the submit
function which is in the prototype of the form element can't be executed.
Example:
<form class="form" id="form" action="/mailer.php" method="post">
<input type="button" name="submit" value="go"/>
</form>
js:
console.log($("#form")[0].submit); // will be the button element, not the submit function.
jQuery's .submit()
method will call the .submit()
on the original dom element, so the error will happen.
这篇关于属性'提交'对象#< HTMLFormElement>不是一个功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文