1

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.

2
  • I think you should read jQuery's API before asking this kind of things, this one is really easy to find searching a little Commented Feb 21, 2011 at 18:43
  • 1
    @jondavidjohn [who has since deleted his comment] find is not limited to only direct descendants; it searches the whole tree below the context Commented Feb 21, 2011 at 18:43

3 Answers 3

6

Use children:

$(this).children('p')

Sign up to request clarification or add additional context in comments.

Comments

1

$(this).children('elementnode')

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

Comments

1

> searches the children of the given element.

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

$('> p', this);

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.