如何选择嵌套元素

时间:2012-10-13 08:12:58

标签: jquery

在此HTML中:

<div class="seal">
    <div class="how with"> </div>
    <div class="how"> </div>
    <div class="with"> </div>
</div>

如何选择此嵌套元素?:

<div class="how with"> </div>

2 个答案:

答案 0 :(得分:1)

jQuery选择器像CSS选择器一样工作:

$('.seal .how.with')

答案 1 :(得分:1)

<div class="seal">

    <div class="how with"> </div>
    <div class="how"> </div>
    <div class="with"> </div>
</div>

选择器.seal:

var seal = jQuery(".seal");

selector .how

jQuery(".how", seal);

选择.with

jQuery(".with", seal);

selector .how和.with

jQuery(".how.with", seal);

jQuery(".seal .how.with");