Value of submit button clicked

后端 未结 6 2127
眼角桃花
眼角桃花 2021-02-07 08:58

This should be really straight forward.

I\'m checking if a form is being submitted using jquery. The form has multiple submit buttons with various values:



        
6条回答
  •  独厮守ぢ
    2021-02-07 09:59

    You can't if you're using the "submit" event. A form can be submitted without ever hitting a submit button.

    In order to obtain which button was clicked, you need to alter your approach by using custom events and marking down which button was actually clicked (creating a selector that can catch click on any of the X buttons in the form). That also requires binding a custom event and prohibiting submit event of the form itself.

提交回复
热议问题