Reputation: 66320
I have a selector like this:
$(source).find('.cb_notes').each(function() { .. } );
I would like to say ignore those .cb_notes
that have any children.
e.g.:
<td class="cb_notes">huhuhu</td>
$($('.cb_notes')[0]).children().length
--> 0 children, hence should be selected
and
<td class="cb_notes">
<span class="shortcontent"> .. </span>
<span class="allcontent"> .. </span>
<span> .. </span>
</td>
$($('.cb_notes')[1]).children().length
--> 3 children, hence should be ignored
Therefore how do I have to modify the slector here:
$(source).find('.cb_notes') ?
Upvotes: 1
Views: 45
Reputation: 382102
Two solutions :
$('.cb_notes', source).filter(function(){return $(this).children().length==0})
$('.cb_notes:not(:has(*))', source)
Upvotes: 4