jQuery: how to get which button was clicked upon form submission?

后端 未结 26 1646
旧巷少年郎
旧巷少年郎 2020-11-22 16:01

I have a .submit() event set up for form submission. I also have multiple forms on the page, but just one here for this example. I\'d like to know which submi

26条回答
  •  不知归路
    2020-11-22 16:34

    It helped me https://stackoverflow.com/a/17805011/1029257

    Form submited only after submit button was clicked.

    var theBtn = $(':focus');
    if(theBtn.is(':submit'))
    {
      // ....
      return true;
    }
    
    return false;
    

提交回复
热议问题