Reputation: 909
My goal is to add a class to all filtered Isotope items.
I am using the getFilteredItemElements
functionality from the Isotpe documentation.
I set a variable equal to all the filtered items as below:
var filteredItems = $grid.isotope('getFilteredItemElements');
This returns me an array of elements:
[div.grid-item.p-1.summer.value1.none, div.grid-item.p-1.summer.value1.none, div.grid-item.p-1.summer.value3.none]
I then wanna add a class to the items in the array by using jQuery .each
.
filteredItems.each(function(){
this.addClass('');
});
But the browser returns Uncaught TypeError: filteredItems.each is not a function
Am I writing a each function incorrect or is it not possible to use .each
in this case?
Upvotes: 0
Views: 807
Reputation: 356
You can also do
[...filteredItems].forEach(elm => elm.classList.add(''));
Upvotes: 1