Discussion:
Find parent form
jogep
2009-06-18 15:01:10 UTC
Permalink
Hello,

i need to find a parent form of an submit button with jquery.

The method

$('#submit').parent("form")

only works when the submit is direct in the form element.
But when I surround the submit element with an div it does not work.

Sample:

This work:
<form action="bla">
<input type="submit" id="submit" />
</form>

This work not:
<form action="bla">
<div>
<input type="submit" id="submit" />
</div>
</form>

How can I find the form element?

Best Regards
Johannes Geppert
Mike Alsup
2009-06-18 15:16:12 UTC
Permalink
Post by jogep
$('#submit').parent("form")
only works when the submit is direct in the form element.
But when I surround the submit element with an div it does not work.
How can I find the form element?
$('#submit').closest("form");

Continue reading on narkive:
Loading...