Search code examples
javascriptjqueryeventstoggleflip

Second click on jQuery


I was wondering what's the easier way to change the .mouseleave for a .click in this Flip Effect:

It's doesnt work just by changing it, I've read about using .toggle but not sure how.

$('.flip').click(function(){
        $(this).find('.card').addClass('flipped').mouseleave(function(){
            $(this).removeClass('flipped');
        });
        return false;
    });

http://jsfiddle.net/nicooprat/GDdtS/

Thanks in advance.


Solution

  • As easy as:

    $('.flip').click(function(){
        $('.card', this).toggleClass('flipped');
        return false;
    });
    

    http://jsfiddle.net/zerkms/GDdtS/2252/