Count immediate child div elements using jQuery

$("#foo > div").length

Direct children of the element with the id ‘foo’ which are divs. Then retrieving the size of the wrapped set produced.

Leave a Comment