Currently, I am in the process of creating a simple image gallery that enlarges an image when it is clicked. To achieve this functionality, I am utilizing jQuery to add and remove classes dynamically.
$(".image").click(function() {
$(this).addClass("big").removeClass("image").css("position", "fixed").animate({
height: '480px',
width: '717px',
top: '5%',
left: '50%',
marginLeft: '-358px',
borderWidth: '40px',
zIndex: '100'
}, "slow");
});
$(".big").click(function() {
$(this).removeClass("big").addClass("image").css("position", "auto").animate({
height: '234px',
width: '350px',
top: 'auto',
left: 'auto',
marginLeft: '0px',
borderWidth: '0px',
zIndex: 'auto'
}, "slow");
});
However, I have encountered an issue where the removal of the image class and addition of the big class works fine, but reversing this process is not functioning as expected. Can anyone point out what mistake I might be making?