Reputation: 5916
HTML looks like this
<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>
now, I want to count the amount of images in the first div 'controllingbuttons', but its parent TR can not have the 'rowinactive' class.
my code previously (when I didnt care about rowinactive yet)
$(".controllingbuttons").first().parent("td").find("img").length
I've been trying this, but it doesnt work:
$(".controllingbuttons").not($(".controllingbuttons").parents(".rowinactive").find(".controllingbuttons")).first().parent("td").find("img").length
any ideas?
Upvotes: 0
Views: 50
Reputation: 29
$(".controllingbuttons").parent('tr:not(.rowinactive)').first()
or
$(".controllingbuttons").closest('tr:not(.rowinactive) td:First').length
Upvotes: 0
Reputation: 74738
You can tryout this:
var imageLen = $(".controllingbuttons").closest('tr:not(.rowinactive)').each(function(){
return $(this).find('img').length;
});
Upvotes: 1
Reputation: 160853
$('tr').not('.rowinactive').find('.controllingbuttons img').length
Upvotes: 2