Skip to content

Instantly share code, notes, and snippets.

@chrdesigner
Created September 17, 2018 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrdesigner/1b8b7d8d9ae6d7dae5e2df3471b15a8e to your computer and use it in GitHub Desktop.
Save chrdesigner/1b8b7d8d9ae6d7dae5e2df3471b15a8e to your computer and use it in GitHub Desktop.
Sub Menu + Filter TAG ~ External
$('.filterBlog a').on('click', function(e) {
filterBlogHash(this.hash, e);
});
$(window).on('load',function() {
filterBlogHash(window.location.hash);
});
function filterBlogHash(hash, e) {
if(hash === '') {
return false;
} else {
if($(hash).length > 0) {
if(typeof e !== 'undefined') {
e.preventDefault();
history.pushState(null, null, $(e.target).attr('href'));
}
var $retunrHash = window.location.hash.substring(1);
$('.filter a.type').each(function (index, value) {
if($retunrHash === $(this).attr('id')){
$(this).get(0).click();
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment