我用java / jsp开发一个带有2个提交按钮的表单:
<form>
<button name="view_step1" type="submit">
Previous
</button>
<button name="action_step2" type="submit">
Next
</button>
</form>
当用户点击“输入”时,如何执行第二个按钮?
答案 0 :(得分:2)
尝试类似的东西:
document.getElementById("id-of-form-or-somthing-else")
.addEventListener("keyup", function(event) {
event.preventDefault();
if (event.keyCode == 13) {
document.getElementById("id-of-your-second-button").click();
}
});