I have written a function to filter the woocommerce products using isotope js. I am trying to sort out the problem. But the filter is not working.
The HTML looks like
<div class = "filters">
<input type="checkbox" class = "do_this_filter" value=".Hand-Wash">Hand wash<br>
<input type="checkbox" class = "do_this_filter" value=".Machine-Wash">Machine wash<br>
</div>
<ul class ='products'>
<li class="items Hand-wash"></li>
<li class="items Machine-Wash"></li>
</ul>
The jQuery I used is
$( function() {
// init Isotope
var $grid = $('.products').isotope({
itemSelector: '.item',
layoutMode: 'fitRows'
});
// bind filter click
$('.do_this_filter').on( 'click', function() {
var filterValue = $( this ).val();
// use filterFn if matches value
$grid.isotope({ filter: filterValue });
});
// change is-checked class
$('.do_this_filter').each( function( i, buttonGroup ) {
var $buttonGroup = $( buttonGroup );
$buttonGroup.on( 'click', function() {
$buttonGroup.find('.is-checked').removeClass('is-checked');
$( this ).addClass('is-checked');
});
});
});
This didn’t work can anyone help.? Thanks in advance.
Jsfiddle
Try like this: