johnlemon
johnlemon

Reputation: 21509

Jquery this and selectors

How can you select using this the direct children of the element ?

Something like $(this).find('p') but for direct children.

Update : there is a difference between a direct children and a sibling.

Upvotes: 1

Views: 120

Answers (3)

Anurag
Anurag

Reputation: 141909

> searches the children of the given element.

$(this).find('> p');

$('> p', this);

$(this).children('p');

Upvotes: 1

meder omuraliev
meder omuraliev

Reputation: 186752

$(this).children('elementnode')

Anytime you wrap a DOM element with $ you have access to prototypal methods, and children is one of them.

Upvotes: 1

Matt
Matt

Reputation: 44078

Use children:

$(this).children('p')

Upvotes: 6

Related Questions