<html>
<head>
<title>scroll()函數(shù)用法</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函數(shù)庫省略-->
<script>
<!--滾動(dòng)時(shí)頂部導(dǎo)航固定-->
$(function(){
$(window).scroll(function(){
var scro = $(window).scrollTop();
if(scro > 100)
$('#top').addClass('scro');
else
$('#top').removeClass('scro');
});
});
</script>