// Just a few lines of jQuery are used to add a sorting capability based on data-type attribute.
// Super Easy & lightweight!
jQuery(function($) {
$(".filter li").click(function() {
// Store data-type attribute
var catagory = $(this).attr("data-type");
// Hide all the matched elements
$('.objects li').hide();
// if 'catagory' is not defined hide/show all elements ("All" button),
// if catagory IS defined show elements that match catagory variable
(!catagory) ? $('.objects li').hide().fadeIn(1500) : $('li[data-type="' + catagory + '"]').fadeIn(1500);
// Classes for the filter buttons
$('.active').removeClass('active');
$(this).addClass('active');
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.