Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery opposite of $(this)

Tags:

jquery

Is it possible to perform the reverse action of $(this)?

So instead of gettin the this element, it gets everything matching .sb-popular-thumb a but excluding $(this)?

See code below of example. I have marked $(this) with $(reverse) so you can see what I am trying to achieve.

$('.sb-popular-thumb a').hover(
  function () {

    $('.sb-popular').stop().animate({
        height : '168px'                    
    }, 200);

    $(this).siblings('.sb-popular-thumb-title').show();

    $(reverse).siblings('.sb-popular-thumb-overlay').stop().fadeIn(200);

  },
  function () {

    $('.sb-popular').stop().animate({
        height : '140px'                    
    }, 200);

    $(this).siblings('.sb-popular-thumb-title').hide();

    $(reverse).siblings('.sb-popular-thumb-overlay').stop().fadeOut(200);

});
like image 414
Joshc Avatar asked Dec 08 '22 22:12

Joshc


2 Answers

just use :

$('.sb-popular-thumb a').not(this)
                        .siblings('.sb-popular-thumb-overlay')
                        .stop()
                        .fadeIn(200);

It will get all the <a> elements within that class except this.

siblings() will do almost the same, but will only get sibling elements (duh) ?

like image 110
adeneo Avatar answered Jan 09 '23 05:01

adeneo


This will imitate your 'reverse'

$('.sb-popular-thumb a').not($(this));
like image 30
Pavel Staselun Avatar answered Jan 09 '23 03:01

Pavel Staselun