Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
48
rated 0 times [  53] [ 5]  / answers: 1 / hits: 39759  / 12 Years ago, wed, january 23, 2013, 12:00:00

can I select #id > #id with jQuery?



I've got this structure



<div id=slide1>
<div id=slide_body>
some content
</div>
</div>

<div id=slide2>
<div id=slide_body>
some content
</div>
</div>


Is there a way to select, using jquery, only the #slide_body inside #slide1?



Or is the only solution to append the id to each body div like



<div id=slide2>
<div id=slide_2_slide_body>
some content
</div>
</div>

More From » jquery

 Answers
4

You can't use unique IDs in one document




This attribute assigns a name to an element. This name must be unique
in a document.




http://www.w3.org/TR/html401/struct/global.html#h-7.5.2



In your example you may use class slide_body



<div id=slide1>
<div class=slide_body>
some content
</div>
</div>


And then you can select it with #slide1 .slide_body or $(#slide1).find('.slide_body')


[#80685] Tuesday, January 22, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
reina

Total Points: 241
Total Questions: 82
Total Answers: 94

Location: New Caledonia
Member since Thu, Mar 23, 2023
1 Year ago
;