随下拉前进的顶部进度条

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>随下拉前进的顶部进度条</title>
          <script type="text/javascript" src="jquery-easyui-1.5/jquery.min.js"></script> 
    <style type="text/css">
 *{margin:0;}
.top-progress{position: fixed;top: 0;height: 2px;width: 100%;z-index: 999}
.bar{height: 2px;background: #ec4657;width:0 }
.high{height:5680px; }
    </style>
</head>
<body>
<div class="top-progress">
    <div class="bar"></div>
</div>
 <div class="high"></div>
 <script type="text/javascript">    
 $(function(){
   $(window).scroll(function () {
       var bodyWidth=$('body').width();
    var scrollTop=$(window).scrollTop();
    var docHeight=$(document).height()
    var winHeight=$(window).height()
    $('.bar').width(bodyWidth*scrollTop/(docHeight-winHeight));
   })
})
 </script>
</body>
</html>
来都来了,留个言吧🙂