I think it's JQuery.dir that would need editing to something like
jQuery.dir = function( elem, dir, limit ){
var matched = [], cur = elem[dir], n = 0;
while ( cur && cur != document ) {
if ( cur.nodeType == 1 && !limit || limit < 0 )
matched.push( cur );
cur = cur[dir];
n++;
}
return matched;
};
to allow the limit on parents as parent and parents use the same .dir
function.
(unfortunately I am still crap some my code is probably wrong :( )
On Apr 9, 12:37 pm, Gilles <[email protected]> wrote:
> I would prefer Mike 2nd approach, not sure the this.each is required
> if it does the job without it, it's just adding on top.
>
> Personally I like the findParent(e,i) idead as when you need only few
> nodes it should improve performance a bit
>
> Query.fn.findParent = function( i ) {
>
> return this.each(function(){
> $(this).addClass(cls).siblings('.'+cls).removeClass(cls);
> })
> };
>
> On Apr 8, 3:53 pm, Nicolas R <[email protected]> wrote:
>
> > radioClass is quite a good idea. Could also be written as
>
> > Query.fn.radioClass = function( cls ) {
> > return this.each(function(){
> > $(this).addClass(cls).siblings('.'+cls).removeClass(cls);
> > })
> > };
>
> > On Apr 6, 2:12 am, "Michael Geary" <[email protected]> wrote:
>
> > > Here's an implementation of .radioClass(). I haven't tested it, but it's
> > > so
> > > simple it's likely to work. :-)
> > > jQuery.fn.radioClass = function( cls ) {
> > > this.addClass(cls).siblings().removeClass(cls);
> > > return this;
> > > };
>
> > > Or alternatively, I think this would work too:
> > > jQuery.fn.radioClass = function( cls ) {
> > > return this.addClass(cls).siblings().removeClass(cls).end();
> > > };
> > > -Mike
>
> > > _____
>
> > > From: Cloudream
>
> > > .radioClass
> > > Add class in one element and remove that same class if it exists from all
> > > of
> > > its siblings in one call.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---