I found different alternatives to toggle here for jQuery 1.9, but I don't get it to work im my case here:
$('.thumb.flip').toggle(
function () {
$(this).find('.thumb-wrapper').addClass('flipStop');
},
function () {
$(this).find('.thumb-wrapper').removeClass('flipStop flipIt');
}
);
You can give .flip a data-attribute
<div class="thumb flip" data-clicked="0">
$('.thumb.flip').click(function () {
var data = $(this).data('clicked'), $descendant=$(this).find('.thumb-wrapper');
if (data) {
$descendant.removeClass('flipStop flipIt');
} else {
$descendant.addClass('flipStop');
}
data == 0 ? $(this).data('clicked', 1) : $(this).data('clicked', 0);
});
Or you can use elseif
$('.thumb.flip').click(function () {
if ($(this).find('.thumb-wrapper').hasClass('flipstop')) {
$(this).find('.thumb-wrapper').removeClass('flipStop flipIt');
} else {
$(this).find('.thumb-wrapper').addClass('flipStop');
}
});
You can use "click" event and then check using ":visible" (if the element is visible at the moment):