更新时间:2022-12-11 15:03:16
您可以将自定义点击处理程序附加到所有按钮,这样您可以在提交表单之前检查单击了哪个按钮:
you can attach a custom click handler to all buttons, and that way you can check which button is clicked before submitting the form:
$("#my-form button").click(function(ev){
ev.preventDefault()// cancel form submission
if($(this).attr("value")=="button-one"){
//do button 1 thing
}
// $("#my-form").submit(); if you want to submit the form
});