Returns true if every element in the collection satisfies the provided testing selector, function or element.
var shapes = Pablo(),
outcome;
shapes.add(Pablo.rect());
shapes.add(Pablo.rect());
shapes.add(Pablo.rect());
shapes.add(Pablo.circle()); // Change me
// Check if all elements are rects
outcome = shapes.every('rect');
alert(outcome);
Note that Internet Explorer 9 requires that the elements have been added to the DOM before the selector check will work.
You may want to use a function when you require a more granular check.
var shapes = Pablo(),
outcome;
shapes.add(Pablo.rect({width: 50, height: 50}));
shapes.add(Pablo.rect({width: 50, height: 50}));
shapes.add(Pablo.rect({width: 50, height: 50}));
shapes.add(Pablo.rect({width: 20, height: 80})); // Change me
// Check if all elements are squares
outcome = shapes.every(function (elem) {
if (Pablo(elem).attr('width') === Pablo(elem).attr('height')) {
return true;
}
});
alert(outcome);