<form method="POST" onsubmit="return false;">
...
<input type="submit" name="button" value="Login" onclick="require('file.js').submitForm(this.form);">
...
</form>
如何在Internet Explorer 9中使用JavaScript触发此INPUT元素的onclick事件(以便它可以提交表单)? 我想:触发输入/表单的onclick事件
document.getElementsByName("button")[0].click()
和
document.getElementsByName("button")[0].onclick()
但既不工程。
(document.getElementsByName( “按钮”)。长度= 1)
你会得到任何错误?你确定这是表单上的第一个按钮吗?你可以添加一个ID到按钮并通过ID获取元素? – Goose
[fireEvent MSDN](http://msdn.microsoft.com/en-us/library/ie/ms536423(v = vs.85).aspx) – Givi
不,我没有看到任何可见的错误,但我知道什么是错的 - 如果我留下一些空白处,表单没有提交。当我把正确的值在字段中使用click()方法正确提交。 – Kossak