直接上代码,一看就懂!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.11.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(window).scroll(function(){
var h=$(this).scrollTop();//获得滚动条距top的高度
//alert(h);
if(h>100){
$("#xianshi").fadeIn();
}else{
$("#xianshi").fadeOut();
}
});
</script>
<style type="text/css">
#test{
width:300px;
height:700px;
margin-top:100px;
background-color:#09C;
}
#xianshi{
width:100px;
height:100px;
position:fixed;
bottom:200px;
left:600px;
background-color:#36C;
display:none;
}
</style>
</head>
<body>
<div id="test">
</div>
<div id="xianshi">
</div>
</body>
</html>