87,910
社区成员
发帖
与我相关
我的任务
分享
var $div = $("div");
$div.queue("q", [
function( next ){ alert("队列函数1"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数2"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数3"); $(this).dequeue("q"); }
]);
$("#btn").click( function(){
$div.dequeue("q");
} );
$(function(){
$("#btn").click( function(){
$div.dequeue("q");
} );
});
$(function(){
var $div = $("div");
$div.queue("q", [
function( next ){ alert("队列函数1"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数2"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数3"); $(this).dequeue("q"); }
]);
$("#btn").click( function(){
$div.dequeue("q");
} );
});
那就改成这样吧,主要原因是var $div = $("div");这句代码执行时,页面的div还没加载,所以不好用,
全放到$(function(){})里就行了,不担心位置
<script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<html>
<head>
</head>
<body>
<div>
</div>
<input type="button" value="test" id="btn">
</body>
</html>
<script type="text/javascript">
var $div = $("div");
$div.queue("q", [
function( next ){ alert("队列函数1"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数2"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数3"); $(this).dequeue("q"); }
]);
$(function(){
$("#btn").click( function(){
$div.dequeue("q");
} );
});
</script>
[/quote]
好吧,问题的关键其实是没有用$(document).ready(function(){{});
汗,,,低级错误啊,,,,但不知为什么没有报错,,,,,,,,,,
<script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<html>
<head>
</head>
<body>
<div>
</div>
<input type="button" value="test" id="btn">
</body>
</html>
<script type="text/javascript">
var $div = $("div");
$div.queue("q", [
function( next ){ alert("队列函数1"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数2"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数3"); $(this).dequeue("q"); }
]);
$(function(){
$("#btn").click( function(){
$div.dequeue("q");
} );
});
</script>
[/quote]
我知道原因了,你试一下我这个调整位置后的代码,居然是位置问题引起的,,,
很奇怪的bug吧
<html>
<head>
<script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
var $div = $("div");
$div.queue("q", [
function( next ){ alert("队列函数1"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数2"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数3"); $(this).dequeue("q"); }
]);
$(function(){
$("#btn").click( function(){
$div.dequeue("q");
} );
});
</script>
</head>
<body>
<div>
</div>
<input type="button" value="test" id="btn">
</body>
</html>
<script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<html>
<head>
</head>
<body>
<div>
</div>
<input type="button" value="test" id="btn">
</body>
</html>
<script type="text/javascript">
var $div = $("div");
$div.queue("q", [
function( next ){ alert("队列函数1"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数2"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数3"); $(this).dequeue("q"); }
]);
$(function(){
$("#btn").click( function(){
$div.dequeue("q");
} );
});
</script>
var $div = $("div");
$div.queue("q", [
function( next ){ alert("队列函数1"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数2"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数3"); $(this).dequeue("q"); }
]);
$(function(){
$("#btn").click( function(){
$div.dequeue("q");
} );
});
我的好用啊,依次alert了啊[/quote]
把你用的浏览器,jquery版本,全部代码包括html发一下,谢谢,,
var $div = $("div");
$div.queue("q", [
function( next ){ alert("队列函数1"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数2"); $(this).dequeue("q"); } ,
function( next ){ alert("队列函数3"); $(this).dequeue("q"); }
]);
$(function(){
$("#btn").click( function(){
$div.dequeue("q");
} );
});
我的好用啊,依次alert了啊