Skip to content Skip to sidebar Skip to footer

Jquery - Run Function On Each Element Except The One That Was Clicked

As some example code, I might have something like this: $('a.parent').click(function(){ $('a.parent').each(function(){ $(this).stop(true,false).animate({

Solution 1:

you can use :not(this) so change :

 $('a.parent').each(function(){
            $(this).stop(true,false).animate({
                width: '140px'
            },200,function(){
            });
        });

to :

$('a.parent:not('+this+')').each(function(){
            $(this).stop(true,false).animate({
                width: '140px'
            },200,function(){
            });
        });

or use .not(this) after $('a.parent') , so :

$('a.parent').not(this).each(function(){
                $(this).stop(true,false).animate({
                    width: '140px'
                },200,function(){
                });
            });

Post a Comment for "Jquery - Run Function On Each Element Except The One That Was Clicked"