I am having some trouble figuring out how to get the number of elements that match a value. Here is my rough code:
var $numElements = $('#casestudy-content article').length;
console.log($numElements);
$('#casestudy-content article').each(function() {
var $leftElements = $(this).position().left;
if ( $leftElements === 0 ) {
console.log($leftElements);
}
});
So I can count how many elements there are in total. I can find the elements that have a position left of 0… but I do not know how to count those elements that return 0. I need to find how many elements = left: 0; and multiply that by a number. Any suggestions?
Thanks,
You can use
filtermethod.