Having tested various solutions found here and on the rest of the web, I can't figure out the logic to do this the "simple" way (or make it work at all).
I have the following list:
<ul class="store-list">
<li data-categories="Bags Shoes Accessories Belts">
<h3 itemprop="name">Enzo Poli</h3>
</li>
<li data-categories="Womenswear Shoes">
<h3 itemprop="name">Ilse Jacobsen</h3>
</li>
<li data-categories="Menswear Womenswear Shoes Ties">
<h3 itemprop="name">Kiman (Shoes Ties)</h3>
</li>
<li data-categories="Menswear Womenswear Shoes Knitwear">
<h3 itemprop="name">Riccovero</h3>
</li>
</ul>
<button class="a">Ties</button>
<button class="b">Ties & Shoes</button>
<button class="c">Menswear</button>
I've tried using Attribute Not Equal Selector, but that definitely does not work.
var stores = $('.store-list');
$('button.b').on('click', function(){
stores.find('li[data-categories!="Ties"][data-categories!="Shoes"]').fadeOut();
});
Another problem is when I select a different categories, the hidden elements are not shown.
I know I can use $.each() and go through each element and use a lot of code to see if it contains the category and check if it's visible or not. But I was just hoping there would be a better and simpler alternative.
So the Q is; How can I show / hide list items based on what filters I select?
See my fiddle here.
lielement at click ofbutton?.filter(); though could substitute addingdata-*tobuttonelement for testing againstbutton.innerHTML