I could not comment on that post, that's why I posted a similar question.(I must have at least 50 reputation for that)
I wanted to know why it is not shrinking, I understood the code exactly as this question's 1st answer was and then tried to code exactly same so that the results be same but nothing happened after scrolling my div
's size remained same
Here's my entire code:
<html>
<div id="header_nav"></div>
<div class="container">
....
</div>
</html>
<style>
.container{padding-top:100px;}
body {
height: 500px;s
width: 100%;s
background-color: #00000;
}
#header_nav {
width: 100%;
height: 100px;
background-color: #666;
position: fixed;
top: 0;
left: 0;
}
</style>
<script>
$(function(){
$('#header_nav').data('size', 'big');
});
$(window).scroll(function(){
if ($(document).scrollTop() > 0) {
if ($('#header_nav').data('size') === ('big')) {
$('##header_nav').data('size','small');
$('#header_nav').stop().animate({
height: '40px'
}, 600);
}
}
else{
if ('#header_nav'.data('size') === ('small')) {
$('#header_nav').data('size','big');
$('#header_nav').stop().animate({
height: '100px'
}, 600)
}
}
});
</script>