Search code examples
javascriptjqueryliveaddclass

Start action after second click at element class with jQuery


i have small problem with my jquery function and i need help. So, i have button with close function but this close function must be fire up after some special class added. So at first click at this close button i'm adding class .major_list. Now i need to close some panel after this specify class click... It's working but panel closing after first click when i use .live function, co you help my how to do this after second click and click at class .major_list?

this is my code:

$('.bottom_panel_button_01').click(function(){
    $(this).addClass('major_list');
});

$('.major_list').delay(300).live('click', function(){
    setTimeout(function(){
    },600).stop(true,true);
});

much thx for help!


Solution

  • $('.bottom_panel_button_01').click(function(){        
        if ($(this).hasClass("major_list")) {
            /* close */
        } else {
            $(this).addClass('major_list');
        }
    });