Pete
Pete

Reputation: 58432

jquery get list of all elements that weren't filtered

say I have the following code:

var filteredList = originalList.filter(function(index) {
    var text = $(this).text();
    return text.toUpperCase().indexOf(filter) !== -1;
});

is there a fast way of getting all the items that were not returned in filteredList or would I have to do the same query but where strpos === -1?

Upvotes: 1

Views: 36

Answers (1)

zerkms
zerkms

Reputation: 254916

jQuery's .not() accepts jQuery object as a parameter as well:

var notFilteredList = originalList.not(filteredList);

jsfiddle

Upvotes: 2

Related Questions