$('#yearscontent div')
selects all divs below #yearscontent
. If you use $('#yearscontent > div')
, it will select only the direct descendant of #yearscontent
.
Also, element id's need to be unique, so you'll need to rework your html/script a little bit. I would use classes instead.
Updated fiddle: http://jsfiddle.net/N5euG/
Update to answer your question in the comments
Consider this html:
<div id="topDiv">
<div id="div1">
<div id="div2">
<div id="div3"></div>
</div>
</div>
</div>
<div id="div4"></div>
#topDiv div
will select #div1
, #div2
, and #div3
. Any div
s within #topdiv
#topDiv > div
will select only #div1
. Just the direct descendant of #topDiv
.