[jQuery] Look for parent with $.findParent(Expr)
Hi,
I am sharing my function that finds a parent by expression. Note that this is different from parent() and parents() as it loops up until it finds a node that corresponds to the expression.
jQuery.fn.findParent
= function(c) {
return this.pushStack(jQuery.map(this, function(a) {
while (a = a.parentNode) {
if (jQuery.filter(c,[a]).r.length) return a;
}
}));
};
Regards,
Konstantin
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/