How to target The First Div Within a Series of Divs in JQuery

Go To StackoverFlow.com

1

I have a list of Divs within another div and I want to only target the first one.

<div id="content">
  <div>
    I want to target this Div
  </div>

  <div>
  </div>

  <div>
  </div>
</div>

How would I target only the first one and leave the rest alone?

2012-04-05 00:40
by Talon


2

You can also do this:

$('#content div').first()
2012-04-05 00:45
by Ethan Brown


1

try $('#content div:first').

2012-04-05 00:42
by John W
Ads