sanders
sanders

Reputation: 10898

Jquery equivalent for every in mootools

In Mootools you have an array method called every. It's descripton is:

Returns true if every element in the array satisfies the provided testing function. This method is provided only for browsers without native Array:every support.

As an example code:

var bAdd = this.selectList.getElements('li').every(
                    function(elm) {
                        return (elm.id != this.id);
                    }, option);

What would be the equivalent in jquery? I guess not each?

Upvotes: 2

Views: 128

Answers (2)

Arvind Bhardwaj
Arvind Bhardwaj

Reputation: 5301

jQuery's each function is what you want.

$("li").each(function(i, el) {
 ...
});

Upvotes: 0

Arun P Johny
Arun P Johny

Reputation: 388396

AFAIK there is no inbuilt support for this.

Assuming this.selectList is an dom element reference

var $lis = $(this.selectList).find('li');
var bAdd = $lis.filter($.proxy(function(elm) {
    return (elm.id != this.id);
}, option)).length == $lis.length;

Upvotes: 1

Related Questions