Skip to content

Instantly share code, notes, and snippets.

@ihorduchenko
Last active September 6, 2017 10:35
Show Gist options
  • Save ihorduchenko/4c1ca89ab804deee93007f98619a2f70 to your computer and use it in GitHub Desktop.
Save ihorduchenko/4c1ca89ab804deee93007f98619a2f70 to your computer and use it in GitHub Desktop.
Filter portfolio items through hash
function filterPortfolio() {
var hash = window.location.hash.substring(1);
var $portItem = $(".tag-block");
var $filter = $(".filter-tabs li a");
if (hash) {
$filter.parent().removeClass("is-active");
$portItem.removeClass("animate is-show").hide();
$portItem
.filter("[data-tags~='" + hash + "']")
.addClass("is-show")
.show();
$filter
.filter("[href~='#" + hash + "']")
.parent().addClass("is-active")
}
}
filterPortfolio();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment