Multiple selector of elements selected via tree traversal


How to select all this elements in only one line via jQuery ?

I thought of this solution, but hope that there is something better :


$('.select_me').fadeOut(); // I select all the previous elements in only 1 line.


You can do it using filter() and index()

Live Demo

idx = $('.myclass').parent().index();
    return  $(this).index() > idx -3 && $(this).index() < idx + 3;

Live Demo

    currentObject = $(this);
    parent = $(this).parent();
      return  $(this).index() > parent.index() -3 && $(this).index() < parent.index() + 3;

Like this?

$.merge($('.myclass'), $('.myclass').parent().siblings()).fadeOut();

Need Your Help

NSMutableArray sortedArrayUsingDescriptors: requires intermediate results array

ios objective-c nsmutablearray nsarray

sortedarrayusingdescriptors doesn't appear to do an in-place sort as I'd hoped.

Confusing error from | xargs sed

git bash replace sed xargs

I have a little find-replace utility around git. Let's ignore suggestions for a different approach ATM. I'm really trying to understand this error from sed. Take a look at the command