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');
}
});