Posted By

nicholascamp on 09/23/11


Tagged

tabs


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

spee66


Tabs


 / Published in: jQuery
 

URL: http://www.getskeleton.com/src/javascripts/tabs.js

  1. /*
  2. * Skeleton V1.1
  3. * Copyright 2011, Dave Gamache
  4. * www.getskeleton.com
  5. * Free to use under the MIT license.
  6. * http://www.opensource.org/licenses/mit-license.php
  7. * 8/17/2011
  8. */
  9.  
  10.  
  11. $(document).ready(function() {
  12.  
  13. /* Tabs Activiation
  14. ================================================== */
  15.  
  16. var tabs = $('ul.tabs');
  17.  
  18. tabs.each(function(i) {
  19.  
  20. //Get all tabs
  21. var tab = $(this).find('> li > a');
  22. tab.click(function(e) {
  23.  
  24. //Get Location of tab's content
  25. var contentLocation = $(this).attr('href');
  26.  
  27. //Let go if not a hashed one
  28. if(contentLocation.charAt(0)=="#") {
  29.  
  30. e.preventDefault();
  31.  
  32. //Make Tab Active
  33. tab.removeClass('active');
  34. $(this).addClass('active');
  35.  
  36. //Show Tab Content & add active class
  37. $(contentLocation).show().addClass('active').siblings().hide().removeClass('active');
  38.  
  39. }
  40. });
  41. });
  42. });

Report this snippet  

You need to login to post a comment.