Javascript 从div的底部计算底部

Javascript 从div的底部计算底部,javascript,jquery,html,Javascript,Jquery,Html,我想从div的底部获取底部值。但在控制台日志中,我一个接一个地得到了2个值。第一个是底部值,第二个是1051.1666870117188。但我只想要第一个值。为什么我会遇到这样的问题。我的代码是 function get_bottom(){ $elem1 = $('.your-cart'); var bottom = $(document).height() - ($elem1.offset().top + $elem1.height());

我想从div的底部获取底部值。但在控制台日志中,我一个接一个地得到了2个值。第一个是底部值,第二个是1051.1666870117188。但我只想要第一个值。为什么我会遇到这样的问题。我的代码是

function get_bottom(){
        $elem1 = $('.your-cart');   
        var bottom = $(document).height() - ($elem1.offset().top + $elem1.height());

        console.log(bottom);
}

$(document).scroll(get_bottom);

试试这个,它会给你想要的

 var bottom = $('#bottom').position().top+$('#bottom').outerHeight(true)