我该如何更有效地编写它?jquery - 重复动画X次
HTML
<div class="navigation-left">left</div>
<div class="navigation-right">right</div>
的js
$(document).ready(function(){
var offs = 0,
speed = 700;
$('.navigation-left').animate({
left: offs,
opacity: 0
}, speed)
.animate({
left: 70 + offs,
opacity: 100
}, speed)
.animate({
left: offs,
opacity: 0
}, speed)
.animate({
left: 70 + offs,
opacity: 100
}, speed)
.animate({
left: offs,
opacity: 0
}, speed)
.animate({
left: 70 + offs,
opacity: 100
}, speed)
.animate({
left: offs,
opacity: 100
}, speed);
$('.navigation-right').animate({
right: offs,
opacity: 0
}, speed)
.animate({
right: 70 + offs,
opacity: 100
}, speed)
.animate({
right: offs,
opacity: 0
}, speed)
.animate({
right: 70 + offs,
opacity: 100
}, speed)
.animate({
right: offs,
opacity: 0
}, speed)
.animate({
right: 70 + offs,
opacity: 100
}, speed)
.animate({
right: offs,
opacity: 100
}, speed);
});
想在这里看到的jsfiddle:http://jsfiddle.net/klawisz/nESMD/
你还必须将对象移到其原始位置 – jb10210 2012-03-27 14:30:14
最初的例子不移动的对象到原来的位置。 – gabitzish 2012-03-27 14:33:33
是的,仔细观察。不透明度也设置为100 – jb10210 2012-03-27 14:43:01