jQuery Filterable Portfolio


/ Published in: jQuery
Save to your folder(s)

This is how NetTuts does their filterable Portfolio.


Copy this code and paste it in your HTML
  1. $(document).ready(function() {
  2. $('ul#filter a').click(function() {
  3. $(this).css('outline','none');
  4. $('ul#filter .current').removeClass('current');
  5. $(this).parent().addClass('current');
  6.  
  7. var filterVal = $(this).text().toLowerCase().replace(' ','-');
  8.  
  9. if(filterVal == 'all') {
  10. $('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
  11. } else {
  12.  
  13. $('ul#portfolio li').each(function() {
  14. if(!$(this).hasClass(filterVal)) {
  15. $(this).fadeOut('normal').addClass('hidden');
  16. } else {
  17. $(this).fadeIn('slow').removeClass('hidden');
  18. }
  19. });
  20. }
  21.  
  22. return false;
  23. });
  24. });

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.