I have an image... what i want : when i click it, it should be scaled bigger and a class called "close" should be added to it. So, when i click it again, the image should be resized to its original size and i want to remove the class in the same time that it could be clicked again to grow... I added successfully a class but i can not remove it.
THE HTML :
<div class="intro-img">
<img src="uploads/images/2.jpg" alt="Sensuality 1" />
</div>
THE CSS :
.intro-img {
position: relative;
display: block;
height: 80%;
max-width: 80%;
margin: 5% auto;
}
.intro-img img {
height: 100%;
max-width: 100%;
cursor: pointer;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.intro-img img:hover {
height: 105%;
max-width: 105%;
}
THE SCRIPT :
$('.intro-img img').click(function(){
$('.intro-img img').addClass( 'close');
$('.intro-img').animate({'height':'100%','max-width':'100%','margin': '0 auto'}, 500, 'easeInCirc');
});
$('.intro-img .close').click(function(){
$('.intro-img').animate({'margin': '5% auto','height':'80%','max-width':'80%'}, 500, 'easeInCirc');
$(this).removeClass('close');
});
How to remove the "close" class by the second click ? What is wrong with my script ? (I read a post about it here but i could not use it to my case)