Hey folks. I am using a little bit of jQuery to do a live sort of my portfolio when various categories are selected. Basically, the script matches the content of an <li>
tag on click (my menu) with the class names of other <li>
tags elsewhere on the page. The result is the portfolio items match the nav clicked will show and hide the rest. A live sort. However, i want to add the ability to add a permalink to activate the jquery to sort by a hashtag at the end.. for example: work.html#category1
would automatically set the script to hide everything but category one. My script and basic page setup is below. Any help would be greatly appreciated!
<script>
$(document).ready(function() {
$('#worknavwrap p a').click(function() {
$(this).css('outline','none');
$('ul#worknavwrap .current').removeClass('current');
$(this).parent().addClass('current');
var filterVal = $(this).text().toLowerCase().replace(' ','_');
if(filterVal == 'all') {
$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
} else {
$('ul#portfolio li').each(function() {
if(!$(this).hasClass(filterVal)) {
$(this).fadeOut('normal').addClass('hidden');
} else {
$(this).fadeIn('slow').removeClass('hidden');
}
});
}
return false;
});
});
</script>
<ul id="worknavwrap">
<li><a href="#category1">Category 1</a></li>
<li><a href="#category2">Category 2</a></li>
<li><a href="#category3">Category 3</a></li>
</ul>
<ul id="portfolio">
<li class="category1">Item 1</li>
<li class="category1">Item 2</li>
<li class="category2">Item 3</li>
<li class="category1">Item 4</li>
<li class="category3">Item 5</li>
<li class="category3">Item 6</li>
<li class="category2">Item 7</li>
<li class="category1">Item 8</li>
</ul>