Javascript 使用自定义按钮提交表单?
想象一个带有多个提交按钮的 HTML 表单, 我正在尝试编写 javascript 函数来使用一个特定按钮提交此表单, 通常我们使用:
form.submit();
但它没有指定按下哪个按钮,
有什么想法吗?
Imagine an HTML form with multiple submit buttons,
Im trying to write javascript function to submit this form with one specific button,
usually we use:
form.submit();
but it doesnt specify which button is pressed,
any Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
直接开火就可以了?
或者,如果您想直接触发表单的提交按钮,为什么不呢
Just fire it directly?
Or if you're wanting to fire the submit button directly of a form, why not
使用 jQuery,您可以在绑定到所需按钮上的单击事件的事件处理程序中提交表单:
Using jQuery, you'd submit the form in an event handler that is bound to the click event on the desired button: