$( "#btn1" ).click(function() {
var $this = $(this);
var clickCount = ($this.data("click-count") || 0) + 1;
$this.data("click-count", clickCount);
if (clickCount%2 == 0) {
$("#img1").hide('clip').animate({
marginLeft: "40%"
},1500);
} else {
$("#img1").show('clip').animate({
marginLeft: "40%"
},1500);
}
});
Issue arises when the jQuery animation behaves differently after hiding and then showing the image for the third time. The animation speed is faster and does not work properly.