87,907
社区成员
发帖
与我相关
我的任务
分享
<!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>
<title></title>
<script src="../demo/jquery-1.3.2.min.js" type="text/javascript"></script>
</head>
<body style="height:2800px;">
*DIV开始固定在一个位置,当下拉条下拉的高度超过这个DIV 1px的时候,这个DIV变浮动*
<div id="top" style="position:fixed; top:50px; left:50px;">
</div>
<div id="pan" style="width:160px; height:300px; border:dashed 1px black; position:absolute; right:0px; top:300px;">
</div>
<script type="text/javascript">
$(document).ready(function () {
window.onscroll = function () {
var t = $(document).scrollTop();
document.getElementById("top").innerHTML = t;
if (t > 301) {
//当滚动条下拉到一定位置(301)时,怎么怎么地。。。。
$("#pan").css({ "position": "fixed", "top": "0" });
}
else {
$("#pan").css({ "position": "absolute", "top": "300" });
}
}
});
</script>
</body>
</html>
希望对你有点启示,ajax你应该会吧?