Search code examples
jquerycsstwitter-bootstrapdhtmltwitter-bootstrap-2

Twitter Bootstrap 2 on collapse event


is there any way to catch when the collapse menu appears (or when collapse button is clicked by user) ?

i'm using standard bootstrap twitter framework and classes.


Solution

  • TWITTER BOOTSTRAP 2

    It looks like the plugin is adding the class "in" to the active collapse group. So maybe you could do something like.

    if( $('#collapseOne').hasClass('in') ){
    ..do something
    }
    

    EDIT:

    Okay, I don't have anyway of testing right now, so these are kind of just guesses. I am sure you could easily determine when a collapse link was clicked by doing this.

    $('.accordion-toggle').click(function(){
       console.log('clicked');
    });
    

    However if you wanted to know exactly which one was clicked you would probably have to index them.