Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select div inside div inside div with jquery

<div id="tab">     
        <div class="" style="margin: 10px;">
            <div id="someVerylongId1" style="height: 400px; position: relative;">

            </div>
        </div>
        <div class="" style="margin: 10px;">
            <div id="someVerylongId2" style="height: 400px; position: relative;">

            </div>
        </div>
        <div class="" style="margin: 10px;">
            <div id="someVerylongId3" style="height: 400px; position: relative;">

            </div>
        </div>
<div>

I want to select all divs not specifying ids or checking any another attributes, is it possible to do like that?

Here is my try:

$("#tab div div")

but looks like is selecting not exactly correct. Need help.

The problem is, my selector returns more elements that it should

like image 567
Gogol Avatar asked Sep 05 '11 07:09

Gogol


1 Answers

$("div > div", "#tab");

That will select all children of divs using the context of #tab

http://jsfiddle.net/HenryGarle/mHpMM/

like image 141
Henry Avatar answered Oct 28 '22 19:10

Henry