$('.foo').click(function () {
alert("a");
$('.blah').not($(this).parent()).animate({
left: '60px'
});
});
jQuery Traversing with .not
-
10-06-2023 - |
Question
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'});
});
});
La solution 2
Autres conseils
You want to exclude the blah
that's the parent node of the foo
being clicked, so
$('.blah').not(this.parentNode).animate({left:'100px'});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow