mantismamita
5/15/2015 - 12:02 PM

jQuery filtering function

jQuery filtering function

jQuery("#sorting li:first-child").addClass('active');

jQuery('#sorting li').click(function() {
    // Remove the current active class
    // Add the active class to the clicked button
    jQuery('#sorting li.active').removeClass('active');
    jQuery(this).addClass('active');

    // Get the button text (filter value)
    var filterValue = jQuery(this).data('sort');
    console.log(filterValue);

    // If "All", how all hidden items
    if (filterValue === 'all') {
        jQuery('.figure').removeClass('hidden');
        jQuery('[class*="block-grid-"]').children('li.figureo').css('clear', 'none');

    } else {
        // Else, find entries that match
        // and add the class of .hidden
        jQuery('.figure').each(function() {
            if (!jQuery(this).hasClass(filterValue)) {
                jQuery(this).addClass('hidden');
            } else {
                jQuery(this).removeClass('hidden');
                jQuery('.block-grid-').children('li.figure').css('clear',' none');
            }
        });
    }

    return false;
});