Posted By

cfleschhut on 12/03/09


Tagged

jquery tabs fading


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

wanderlusts
enwood
wirenaught


jQuery Tabs


 / Published in: jQuery
 

URL: http://jsbin.com/uxabu

inspired by: http://devthought.com/projects/mootools/barackslideshow/ + http://net.tutsplus.com/tutorials/javascript-ajax/building-an-auto-scrolling-slideshow-that-works-with-and-without-javascript/

  1. var tabPanesContainer = $("ul#tabPanes").css("position", "relative");
  2. var tabPanesAll = tabPanesContainer.find("li").css("position", "absolute");
  3. tabPanesAll.eq(0).addClass("selected").appendTo(tabPanesContainer);
  4. var tabMenuLinks = $("ul#tabMenu a");
  5. tabMenuLinks.click(function() {
  6. var tabClicked = tabPanesAll.filter(this.hash);
  7. if (!tabClicked.hasClass("selected")) {
  8. tabPanesAll.removeClass("selected").filter(this.hash).hide().appendTo(tabPanesContainer).addClass("selected").fadeIn();
  9. }
  10. return false;
  11. });
  12.  
  13.  
  14. <div id="tabs">
  15. <ul id="tabMenu">
  16. <li><a href="#tab1">tab 1</a></li>
  17. <li><a href="#tab2">tab 2</a></li>
  18. <li><a href="#tab3">tab 3</a></li>
  19. </ul>
  20. <ul id="tabPanes">
  21. <li id="tab1">
  22. <h4>Tab 1</h4>
  23. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
  24. </li>
  25. <li id="tab2">
  26. <h4>Tab 2</h4>
  27. <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
  28. </li>
  29. <li id="tab3">
  30. <h4>Tab 3</h4>
  31. <p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  32. </li>
  33. </ul>
  34. </div>
  35.  
  36.  
  37. ul#tabPanes {
  38. width: 740px;
  39. height: 100px;
  40. overflow: hidden;
  41. }
  42. ul#tabPanes li {
  43. width: 740px;
  44. height: 100px;
  45. }
  46. ul#tabPanes li#tab1 { background: red; }
  47. ul#tabPanes li#tab2 { background: green; }
  48. ul#tabPanes li#tab3 { background: yellow; }

Report this snippet  

You need to login to post a comment.