日期:2014-05-16 浏览次数:20349 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<pre>
r
rg
r
g
g
</pre>
<div style="background:green;width:300px;height:300px;"></div>
<pre>
rg
r
gf
gf
g
fgf
gf
g
f
g
g
f
g
fr
r
gr
g
r
g
r
</pre>
<script type="text/javascript"src="jquery-1.5.js"></script>
<script type="text/javascript">
var i=0;
$(window).scroll(function(){
if($("div").offset().top==$(document).scrollTop()){
j=$(document).scrollTop();
if(j>i){
$("div").css("position","fixed");
$("div").css("top",0);
}
i=j;
}else{
j=$(document).scrollTop();
i=j;
$("div").css("position","static");
}
});
</script>
</body>
</html>