Advertisement
hogash

acc fixed

Sep 26th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////
  2. // ACCORDION - Tutorial by Soh Tanaka - http://www.sohtanaka.com/web-design/easy-toggle-jquery-tutorial/
  3. //////////////////////////////////////////////////////////////////////////
  4.  
  5. $('.acc_container').hide(); //Hide/close all containers
  6.  
  7. // if you want to show the first div uncomment the line below <-- read this
  8. //Add "active" class to first trigger, then show/open the immediate next container
  9. //$('.acc_trigger:first').addClass('active').next().show();
  10.  
  11. $('.acc_trigger').click(function(e){
  12. var accCont = $(this).parent().children('.acc_container');
  13. if( accCont.is(':hidden') ) { //If immediate next container is closed...
  14. $('.acc_trigger').removeClass('active').parent().children('.acc_container').slideUp(); //Remove all "active" state and slide up the immediate next container
  15. $(this).toggleClass('active').parent().children('.acc_container').slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
  16. } else {
  17. $('.acc_trigger').removeClass('active').parent().children('.acc_container').slideUp(); //Remove all "active" state and slide up the immediate next container
  18. }
  19. e.preventDefault(); //Prevent the browser jump to the link anchor
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement