0

我有一些代码循环创建行如下

<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)

我遇到的问题是计算不等于 4 且值为 2的link类的数量。data-statusdata-image

4

1 回答 1

1
var links = $('.link q1').filter(function() {
    return $(this).data('status') != '4' && $(this).data('image') == '2';
}).length;
于 2013-02-28T11:18:36.913 回答