Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////
- // ACCORDION - Tutorial by Soh Tanaka - http://www.sohtanaka.com/web-design/easy-toggle-jquery-tutorial/
- //////////////////////////////////////////////////////////////////////////
- $('.acc_container').hide(); //Hide/close all containers
- // if you want to show the first div uncomment the line below <-- read this
- //Add "active" class to first trigger, then show/open the immediate next container
- //$('.acc_trigger:first').addClass('active').next().show();
- $('.acc_trigger').click(function(e){
- var accCont = $(this).parent().children('.acc_container');
- if( accCont.is(':hidden') ) { //If immediate next container is closed...
- $('.acc_trigger').removeClass('active').parent().children('.acc_container').slideUp(); //Remove all "active" state and slide up the immediate next container
- $(this).toggleClass('active').parent().children('.acc_container').slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
- } else {
- $('.acc_trigger').removeClass('active').parent().children('.acc_container').slideUp(); //Remove all "active" state and slide up the immediate next container
- }
- e.preventDefault(); //Prevent the browser jump to the link anchor
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement