Dan Eastwell schrieb: > I know I can use parents to get the ancestors of my input, but this > will get all forms on the page > > $(#myInput).parents("form"); > > How do I find the one the form is in? > > var formItsIn = checkAncestors(theSearchBox, "form"); > > function checkAncestors(theItem, requiredAncestor){ > var theparent = theItem.parentNode.nodeName.toLower(); > if(theparent == requiredAncestor){ > return theparent; > }else{ > checkAncestors(theparent, requiredAncestor); > } > } > > > my code above seems a bit much to me, and it's not jquery! > > Cheers, > > Dan.
Dan, every form element contained by a form has the form property...: var formItsIn = theSearchBox.form Much shorter :-) -- Klaus _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/