我有一些代码可循环创建行,如下所示
<div class='link' data-job_id='123456'>
<div class='holder'>
<img class=q1 src='first_image.jpg' data-status='1' data-image='1' alt='first_image' />
<img class=q1 src='second_image.jpg' data-status='4' data-image='2' alt='second_image' />
</div>//end holder
</div>//end link
<div class='link' data-job_id='456789'>
<div class='holder'>
<img class=q1 src='first_image.jpg' data-status='2' data-image='1' alt='first_image' />
<img class=q1 src='second_image.jpg' data-status='7' data-image='2' alt='second_image' />
</div>//end holder
</div>//end link
....etc (this has been greatly simplified)
我遇到的问题是计算link
不等于4且data-status
值为2的data-image
类的数量。
答案 0 :(得分:1)
var links = $('.link q1').filter(function() {
return $(this).data('status') != '4' && $(this).data('image') == '2';
}).length;