I’ve got a button(#nav-button) that increases an elements height. But I want the same button to also decrease the height when pressed again. The code:
$(document).ready(function(){
$('.nav-button-open').click(function(){
$('.nav-bar').animate({height:'90px'}, 500);
$("#nav-button").attr('class', 'nav-button-close');
});
$('.nav-button-close').click(function(){
$('.nav-bar').animate({height:'10px'}, 500);
$("#nav-button").attr('class', 'nav-button-open');
});
});
Fiddle: http://jsfiddle.net/mdecler/e4XED/
The jQuery increases the height fine but I cannot decrease the height when I press the button again! What am I doing wrong?
Thx for your help!
Consider changing your jQuery code to:
DEMO LINK:
http://jsfiddle.net/e4XED/4/