Reputation: 913
I've coded a column of several red boxes each containing a smaller grey box. When a grey box gets clicked, I want all red boxes to animate left by 100px, except for the red box containing the grey box that was clicked. I know that I need to use some form of .not()
to exclude the child of the red box that I want remaining stationary, however I'm not sure what to put inside of the .not()
parentheses.
http://jsbin.com/taforuxu/2/edit
JS
$(document).ready(function() {
$('.foo').click(function() {
$('.blah').not(???).animate({left:'100px'});
});
});
Upvotes: 0
Views: 40
Reputation: 129001
You want to exclude the blah
that's the parent node of the foo
being clicked, so
$('.blah').not(this.parentNode).animate({left:'100px'});
Upvotes: 2
Reputation: 9947
$('.foo').click(function () {
alert("a");
$('.blah').not($(this).parent()).animate({
left: '60px'
});
});
Upvotes: 1