$(document).on( 'scroll', function() { var dheight=$('body').height()-$(window).height(); if ($(this).scrollTop()>=dheight*.75 && !$('.ontop').hasClass("ontop_showed") && dheight>0) $('.ontop').addClass("ontop_showed"); else if ($(this).scrollTop()