0

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'});
  });
});
Uncle Slug
  • 853
  • 1
  • 13
  • 26

2 Answers2

2

You want to exclude the blah that's the parent node of the foo being clicked, so

$('.blah').not(this.parentNode).animate({left:'100px'});

Demo

Ja͢ck
  • 170,779
  • 38
  • 263
  • 309
icktoofay
  • 126,289
  • 21
  • 250
  • 231
1
  $('.foo').click(function () {
      alert("a");
      $('.blah').not($(this).parent()).animate({
          left: '60px'
      });
  });

Demo