I need help with a div that has its height set to 0px initially, and I want it to increase to 300px when a button is clicked. When the button is clicked again, I want the height to go back to 0px.
Here's the CSS code:
nav{
height:0px;
overflow:hidden;
opacity:0;
}
And here's the JavaScript code:
$("#hamburger").click(function(){
$('nav').stop().animate({ height: 300, opacity: 1 }, 'slow');
},function(){
$('nav').stop().animate({ height: 0, opacity: 0 }, 'slow');
});
When I only use the first part of the JavaScript code, the animation works fine. But as soon as I add the second line, it doesn't work properly. I also tried using the toggle() function, but encountered issues where the height and opacity properties were not behaving as expected.
For more information, you can visit my website here.
If you have any ideas on how to fix this issue, I would greatly appreciate it. Thank you!
EDIT
Just a heads up, I am currently working on making my website responsive. The JavaScript code mentioned above is specifically for the mobile version. To see the result, please adjust your browser width to 480px or less.