-1

DL DT DD を含む 2 つの div があり、div の最後の DT をそれぞれ選択したいと考えています。ただし、最後の DIV から DT のみを選択しています。

HTML:

<div class=pack>
<dl>
<dt>Photos</dt>
<dd>asd</dd>

<dt>Videos</dt>
<dd>asd</dd>

<dt>Infographics</dt>
<dd>ads</dd>
</dl>
</div>

<div class=pack>
<dl>
<dt>Photos</dt>
<dd>asd</dd>

<dt>Videos</dt>
<dd>asd</dd>

<dt>Infographics</dt>
<dd>ads</dd>
</dl>
</div>

jQuery:

$('.pack dl').find('dt').last().css({"background" : "none" });

問題は、jquery が 2 番目の DIV class=pack から最後の DT のみを選択することです。

4

2 に答える 2

1
$('.pack ul').each(function(){
    $(this).find('li').last().css({"background" : "none" });
});
于 2013-02-25T17:04:40.650 に答える
0

@Brad Mに感謝します。各メソッドは機能します。

$('.pack dl').each(function(){
        $(this).find('dt').last().css({"background" : "none" });
    });
于 2013-02-25T17:23:12.940 に答える