Tom Smykowski
Tom Smykowski

Reputation: 26109

How to get all divs below on 1-level with jQuery?

$('#masterDiv div') gets me all the divs below the masterDiv and divs nested in these divs. How to get only 1-level children?

Upvotes: 2

Views: 74

Answers (3)

Thulasiram
Thulasiram

Reputation: 8552

$('#masterDiv').children('div')

Upvotes: 0

Ashwin Krishnamurthy
Ashwin Krishnamurthy

Reputation: 3758

$("#masterDiv").children("div")

Read the docs for more info.

Upvotes: 5

s.webbandit
s.webbandit

Reputation: 17000

Use this $('#masterDiv > div').

It is Child selector.

Upvotes: 7

Related Questions