Jared
Jared

Reputation: 1793

How to select $(this) AND $(this) > child with jQuery?

Can't quite figure this out. If I use:

$('> .someClass', this);

It will select this > .someClass, but I want to select this AND this > child

Tried

  $(this+'> .someClass', this);
//AND
 var currentEl = $(this);
  $(currentEl, currentEl+'> .someClass')

Any help would be appreciated.

Upvotes: 1

Views: 92

Answers (2)

Anthony Grist
Anthony Grist

Reputation: 38345

You can use the .andSelf() function to add this to the set of matched elements, like so:

$(this).find('> .someclass').andSelf();

Upvotes: 1

Blowsie
Blowsie

Reputation: 40535

use andSelf()

$(this).find('> .someclass').andSelf();

andSelf() documentation

Upvotes: 1

Related Questions