plugin devs should remember: Never use $ inside your plugins. Always use
'jQuery'. The reason is that '$' can be changed by the user for support with
other libraries.
On 12/13/06, Jonathan Sharp <[EMAIL PROTECTED]> wrote:
I wrote a method that will provide a list of ancestors for any number of
generations until an ancestor matches the expression. Example:
BODY
DIV
UL.myClass
LI
UL
LI #myId
$('#myId').ancestors()
returns [UL, LI, UL.myClass, DIV, BODY]
$('#myId').ancestors("UL.myClass")
returns [UL.myClass]
Returns all elements up to and including the match expression
$('#myId').ancestorsTo("UL.myClass")
returns [UL, LI, UL.myClass]
Code:
jQuery.fn.ancestorsTo = function(match) {
var j = $();
var b = false;
$(this[0]).ancestors().each(function() {
if (b == false) {
j.add(this);
if ($(this).is(match)) {
b = true;
}
}
});
return j;
};
Cheers,
-js
_______________________________________________
jQuery mailing list
[email protected]<https://mail.google.com/mail?view=cm&tf=0&[EMAIL PROTECTED]>
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/