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.


-- 
Daniel Eastwell

Portfolio and articles:
http://www.thoughtballoon.co.uk

Blog:
http://www.thoughtballoon.co.uk/blog

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to