2
我想讓自定義隊列, 你能告訴我我做錯了什麼嗎?jQuery - 如何編寫自定義隊列?
這裏是行動代碼: http://dl.dropbox.com/u/1292831/hell/index2.html
<!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" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" href="style/style.css" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<style type="text/css">
.tester {
background:red;
width: 100px;
height: 100px;
left: 900px;
top: 300px;
position: absolute;
}
.counter {
position: absolute;
left: 0;
top: 0;
width: 150px;
font-size: 18px;
}
</style>
<script type="text/javascript">
$(function(){
// animation for the 'FX' queue:
$('.tester').fadeOut(1000).fadeIn(1000)
// animation for the 'lolo' queue:
$('.tester').queue('lolo',function(next){
$(this).animate({left: 100}, {duration:1000})
next()
})
$('.tester').queue('lolo',function(next){
$(this).animate({left: 800}, {duration:1000})
next()
})
.dequeue('lolo')
})
// counters
setInterval(function(){
var count = $('.tester').queue('fx').length
$('.counter #c1').html(count)
var count = $('.tester').queue('lolo').length
$('.counter #c2').html(count)
}, 250)
</script>
</head>
<body>
<p class="counter">
items in the 'fx' queue <span id="c1"></span> <br />
items in the 'lolo' queue <span id="c2"></span>
</p>
<div class="tester"></div>
</body>
</html>
謝謝,它的作品就像一個魅力!對於我目前的項目來說,它已經足夠了。 仍然希望找到一種方法來做類似.animate('lolo',{left:100},1000)... – 2011-05-11 20:42:12