jQuery accordion add active

Hendrix

I would like to add an asset on the accordion title?

Add class active?

$(document).ready(function() {
    $(".accordion .accord-header").click(function() {
        if($(this).next("div").is(":visible")){
            $(this).next("div").slideUp("slow");
        } else {
            $(".accordion .accord-content").slideUp("slow");
            $(this).next("div").slideToggle("slow");
        }
    });
    $(".accordion .accord-header:eq(1)").trigger('click');
});

http://jsfiddle.net/ngGqA/

Niffler

Just insert this code before or after your if-else-query:

$('.accord-header.active').removeClass('active');
$(this).addClass('active');

Here's a fiddle: http://jsfiddle.net/Niffler/ngGqA/17/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive