HTML看起來像這樣首先選擇對象,其中家長不上課
<tr class="rowinactive">
<td>
<div class="controllingbuttons">
<a title="Aanpassen" href="/2013-2014/Persoon/Edit/1811?instID=410">
<img width="16" alt="Edit" src="/img/pencil.png">
</a>
...
</td>
</tr>
OR
<tr> (rowinactive class missing)
<td>
<div class="controllingbuttons">
<a title="Aanpassen" href="/2013-2014/Persoon/Edit/1811?instID=410">
<img width="16" alt="Edit" src="/img/pencil.png">
</a>
...
</td>
</tr>
現在,我要算在第一個div圖像數量「controllingbuttons」,但它的父級TR不能有'rowinactive'類。
我的代碼以前(當我沒有在意rowinactive還)
$(".controllingbuttons").first().parent("td").find("img").length
我一直想這一點,但它不工作:
$(".controllingbuttons").not($(".controllingbuttons").parents(".rowinactive").find(".controllingbuttons")).first().parent("td").find("img").length
什麼想法?
我覺得'$('tr')。not('。rowinactive')。find '.controllingbuttons img')。length'將會做,或者最壞的情況是''('tr')。not('。rowinactive')。find('.controlbuttons')。first('img')。length'' –
@ArunPJohny是的,就是這樣。 – xdazz
我確實需要First()。謝謝! – Stefanvds