Pregunta

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'});
  });
});
¿Fue útil?

Solución 2

  $('.foo').click(function () {
      alert("a");
      $('.blah').not($(this).parent()).animate({
          left: '60px'
      });
  });

Demo

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top