How to get the form parent of an input?
Posted
by ropstah
on Stack Overflow
See other posts from Stack Overflow
or by ropstah
Published on 2009-06-13T19:48:17Z
Indexed on
2010/04/19
16:33 UTC
Read the original article
Hit count: 346
Hi,
i need to get a reference to the FORM parent of an INPUT when I only have a reference to that INPUT. Is this possible with javascript (or else jQuery) ?
function doSomething(element) {
//element is input object
//how to get reference to form?
}
This doesn't work:
var form = $(element).parents('form:first');
alert($(form).attr("name"));
© Stack Overflow or respective owner