我已经写了2个JQuery函数,它们应该将9个ID从“C1”设置为“C9”的块并向上滚动,直到它们到达顶部,然后每个块到达顶部应该回去并重新开始。奇怪的是每次他们开始时,块之间的空间变得更大,直到一切都变得混乱。我是JQuery的新手,我很感谢任何帮助,甚至更好的想法,我应该如何做到这一点。 这是代码:JQuery:滚动动画问题
<html>
<head>
<title>Some JQuery Practice</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<link rel="stylesheet" href="style1.css" type="text/css">
<style>
#BOX{
position:absolute;
width:700px;
height:200px;
top:100px;
overflow:hidden;
background-color:#D3C79D;
-moz-border-radius:30px;
}
.content{
font-family:Tahoma;
font-size: 11px;
position:relative;
width:660px;
top:200px;
}
</style>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script>
function OneGoesUp(target){
if(target.position().top == 0){
target.css({"top":"270"});
}
target.animate({
"top": "-=1"
}, 10, function(){OneGoesUp(target)});
}
function GoUp(){
for(var i=1;i<10;i++){
var str = "#c";
str += i;
$(str).text(str);
OneGoesUp($(str));
}
}
</script>
</head>
<body onload="GoUp();">
<div id="BOX">
<div id="c1" class="content"><p>Lorem ipsum</p></div>
<div id="c2" class="content"><p>Lorem ipsum</p></div>
<div id="c3" class="content"><p>Lorem ipsum</p></div>
<div id="c4" class="content"><p>Lorem ipsum</p></div>
<div id="c5" class="content"><p>Lorem ipsum</p></div>
<div id="c6" class="content"><p>Lorem ipsum</p></div>
<div id="c7" class="content"><p>Lorem ipsum</p></div>
<div id="c8" class="content"><p>Lorem ipsum</p></div>
<div id="c9" class="content"><p>ghghjghjghj</p></div>
</div>
</body>
</html>
的党团()函数被调用一次,那是在页面加载时。我是否必须使用Cycle插件来获得这样的效果? 在此先感谢。
请张贴您的html以及。 – Catfish 2010-08-13 21:11:05
我编辑了帖子并添加了HTML – Auxiliary 2010-08-13 21:21:22