如何使用jQuery在div内部的div中选择div
问题描述:
<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>
我想选择所有未指定ID或未检查其他任何属性的div,是否可以这样做?
I want to select all divs not specifying ids or checking any another attributes, is it possible to do like that?
这是我的尝试:
$("#tab div div")
,但看起来选择不完全正确.需要帮助.
but looks like is selecting not exactly correct. Need help.
问题是,我的选择器返回了更多应有的元素
The problem is, my selector returns more elements that it should
答
$("div > div", "#tab");
这将使用#tab的上下文选择div的所有子级
That will select all children of divs using the context of #tab