SHow div when reached bottom
Bisa diganti jadi hide when reached bottom
by xaliber
HTML
<div>
<div class="a">
A
</div>
</div>
CSS
body {
height: 2000px;
}
.a {
height: 300px;
width: 300px;
background-color: green;
position:fixed;
display:none;
}
JavaScript
$(window).scroll(function() {
if ($(this).scrollTop() + $(window).height() >= $(document).height() - 15)
{
$('.a').fadeIn();
}
else
{
$('.a').fadeOut();
}
});
// Why use fadeIn-fadeOut and not .css("display", "block") ?
// cuz it's animate
// and fadein-out already handles display
// Check:
// http://stackoverflow.com/questions/6485813/jquery-animate-opacity-vs-displaynone
// $('.a').fadeout
// else
// fadein