$('#arrow').click(function () {
if ($('#slide1').hasClass("small")) {
$('#slide1').animate({"height": "40px"}, "medium").removeClass("small");
} else {
$('#slide1').animate({"height": "20px"}, "medium").addClass("small");
}
});
You can use the animate
method to change the height
. And hasClass
method to check the condition of the div(is it in the original size or not). Here I have added a class 'small' to indicate the reduced height state.