Reputation: 19251
I was wondering how to count a list of <li>
with a style val = 0 ?
i.e. something like
jQuery('ol.myClass li').each(function () {
if (jQuery(this).css('top') == '0px') {
count = + 1;
}
});
How would I do this so it finds all elements and gives me a figure for all those that have the val = 0 for css('top')
?
Upvotes: 1
Views: 163
Reputation: 2344
I would say try this way.
var list = $("ol.myClass li").filter(function() {
return $(this).css("top") === "0px";
});
list.length
Upvotes: 1
Reputation: 11552
Try something like:
var foo = $('ol.myClass li').filter(function() {
return $(this).css('top') == '0px';
});
Upvotes: 1