<html>
<head>
<title>scroll()函数用法</title>
<style>
#top{hieght:100px;width:100%}
.scro{position: fixed;z-index: 999999;box-shadow: 0 2px 3px #ccc;}
</style>
</head>
<body>
<div id="top"></div>
</body>
</html>
<!--引入jq函数库省略-->
<script>
<!--滚动时顶部导航固定-->
$(function(){
$(window).scroll(function(){
var scro = $(window).scrollTop();
if(scro > 100)
$('#top').addClass('scro');
else
$('#top').removeClass('scro');
});
});
</script>