$(document).ready(function() { $(window).scroll(function() { var a = document.getElementById("bottomdb").offsetTop; if (a >= $(window).scrollTop() && a < ($(window).scrollTop() + window.screen.height)) { $(".friends").hide(); }else{ $(".friends").show(); } }); });