Tiny Sort

Posted in Javascript

This is a little sort function I made for a website I was working on. Totalling in at 12 lines unminified it is in my opinion, the definition of minimal tab sorting.

$(".selector a").click(function() {
  let filter = $(this).attr("filter"),
      item = $(".gallery-item");
  
  if (filter == "all") {
    item.fadeIn(99);
  } else {
    item.each(function(){
      $(this).hasClass(filter) ? $(this).fadeIn(99) : $(this).fadeOut(99);
    });
  }
});

← back to the blog