Trev
Trev

Reputation: 157

How to SELECT the following element in jQuery

I have a group of nested divs

<div id="myDivs">
  <div>
    <div>
      <div></div>
    </div>
    <div></div>
    <div></div>
  </div>
</div>

Using jquery, how do I select the div that is immediately beneathe myDivs, but NONE of it's children?

thnx!

Upvotes: 1

Views: 365

Answers (2)

OOO
OOO

Reputation: 324

Since the first element is an id selector, the following way will faster. But only noticed the difference in a very complex document.

$('#myDivs').find('div')

Upvotes: 0

ThiefMaster
ThiefMaster

Reputation: 318468

Use the child selector: $('#myDivs > div')

Upvotes: 5

Related Questions