How to find the submit button in a specific form in jQuery

后端 未结 7 2382
执念已碎
执念已碎 2020-12-25 09:37

I try to get jQuery object of a submit button in a specific form (there are several forms on the same page).

I managed to get the form element itself. It looks somet

7条回答
  •  没有蜡笔的小新
    2020-12-25 10:29

    Because a HTML5 submit button may be out of form tag http://www.w3.org/TR/html-markup/input.submit.html#input.submit.attrs.form, you can use the following code to find it:

    $(curElement.closest('form').get(0).elements).filter(':submit')
    

提交回复
热议问题