Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
139
rated 0 times [  145] [ 6]  / answers: 1 / hits: 112091  / 14 Years ago, sun, may 23, 2010, 12:00:00

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 something like this:



var curForm = curElement.parents(form);


The current Element has the context HTMLInputElement. The several techniques I tried to get the according submit element of the form:



var curSubmit = curForm.find(input[type='submit']);
var curSubmit = $(curForm).find(input[type='submit']);
var curSubmit = curForm.find(:submit);
var curSubmit = $(curForm).find(:submit);
var curSubmit = $(curSubmit, input[type='submit']);


the result is always the same (and very strange). The result that I get is the same element as curElement.



So how can I get the right submit button?


More From » jquery

 Answers
56

The following should work:



var submit = curElement.closest('form').find(':submit');

[#96707] Wednesday, May 19, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parker

Total Points: 259
Total Questions: 109
Total Answers: 97

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;