Oliver Tappin
Oliver Tappin

Reputation: 2541

This selector AND element within this selector

Is there a way to include both: $(this) and $("h3", this) in the same line?

Maybe something like $("h3,", this)?

I know that's not right but I've never heard of the equivalent.

Upvotes: 2

Views: 56

Answers (1)

Felix Kling
Felix Kling

Reputation: 817208

You can use .andSelf [docs]:

$(this).find('h3').andSelf()

It merges the previously selected elements in the stack ($(this)) with the current selection ($(this).find('h3')).

Upvotes: 9

Related Questions