识别表单的主要提交按钮 [英] Identifying main submit button for a form

查看:87
本文介绍了识别表单的主要提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有几个文本框和两个提交按钮的表单。选择文本框后,按 Enter ,将触发第一个提交按钮。但是,这不是当时应该按下的按钮。我该如何做到这一点,以便当按下 Enter 按钮时,点击第二个提交按钮(或至少是提交按钮的最后一个)?

I have a form which has a few text boxes, and two submit buttons. When a text box is selected, and I press Enter, the first submit button is triggered. However, this is not the button that should be pressed at that time. How can I make it so that when the Enter button is pressed, the second submit button (or at least, the last occurrence of the submit button) clicked?

我有一个目前使用JavaScript的实现,但我希望有一个本地选项。

I have an implementation of this currently using JavaScript, but I'm hoping there is a native option for it.

推荐答案

其获得更多原生JavaScript相当困难。你会在这里需要它。顺便说一句,你注意到的行为是预期的行为。您的html中的第一个提交按钮是一个将随您的标题一起发送的提交按钮。

I guess if you really didn't want to use js, you could just put the other button first and then use css to position them correctly on the page itself.

这篇关于识别表单的主要提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆