如何使用jQuery在div内部的div中选择div [英] How to select div inside div inside div with jquery

查看:479
本文介绍了如何使用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

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

这篇关于如何使用jQuery在div内部的div中选择div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆