首页javascriptscrolljQuery Style - 如何更新底部偏移为滚动窗口

jQuery Style - 如何更新底部偏移为滚动窗口

我们想知道如何更新底部偏移为滚动窗口。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    $(window).scroll(function() {
        console.log($(this).scrollTop());
        $('#myElement').css('bottom', -1*$(this).scrollTop() + "px");
    });
});
</script>
</head>
<body>
  <div style='height: 1000px;background:#EEE'>something for making scrollbars</div>
  <div id="myElement" style="position: absolute; bottom: 0px;">This
    stays at the top</div>
</body>
</html>