Return to Snippet

Revision: 13616
at April 29, 2009 10:26 by conspirator


Initial Code
$(document).ready(function() {
	$('ul#filter a').click(function() {
		$(this).css('outline','none');
		$('ul#filter .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;
	});
});

Initial URL
http://nettuts.s3.amazonaws.com/196_jquery/index.htm

Initial Description
This is how NetTuts does their filterable Portfolio.

Initial Title
jQuery Filterable Portfolio

Initial Tags
list, jquery, filter

Initial Language
jQuery