<style>
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:30px;
background:green; display:none; }
div.newcolor { background:blue; }
</style>
Click here...
<div></div> $(document.body).click(function () {
$("div").show("slow");
$("div").animate({left:'+=200'},2000);
$("div").queue(function () {
$(this).addClass("newcolor");
$(this).dequeue();
});
$("div").animate({left:'-=200'},500);
$("div").queue(function () {
$(this).removeClass("newcolor");
$(this).dequeue();
});
$("div").slideUp();
});
1.看了几天queue了,感觉一点没有理解它的工作方式
2.上面的代码中,当没有点击时,queue函数起不起作用?没有点击时,有没有队列?
3.当点击后,代码的执行顺序是怎么样的,明白的请详细地说一下吧
谢谢
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:30px;
background:green; display:none; }
div.newcolor { background:blue; }
</style>
Click here...
<div></div> $(document.body).click(function () {
$("div").show("slow");
$("div").animate({left:'+=200'},2000);
$("div").queue(function () {
$(this).addClass("newcolor");
$(this).dequeue();
});
$("div").animate({left:'-=200'},500);
$("div").queue(function () {
$(this).removeClass("newcolor");
$(this).dequeue();
});
$("div").slideUp();
});
1.看了几天queue了,感觉一点没有理解它的工作方式
2.上面的代码中,当没有点击时,queue函数起不起作用?没有点击时,有没有队列?
3.当点击后,代码的执行顺序是怎么样的,明白的请详细地说一下吧
谢谢
解决方案 »
- extjs 如何显示list中的内容?
- window.event.cancelBubble问题
- 基于Jquery的一个倒计时的问题(新鲜的逻辑思维)
- javascript 作为潜入到Html中的文件时,如果JS文件中包含汉字,会出现乱码?
- 求疯狂猜图网页版源代码
- js报错,Uncaught SyntaxError: Unexpected token }不知道哪里错,求解答!
- web上打开附件的问题
- 请问如何用javascript判断一个字符串是否为数字、字母?
- 怎样让form提交时开辟一个新窗口呀?
- 求解:javascript Table 操作
- 网页里制作升级进度条
- 文本框初始化函数加了为什么没反应?
<html>
<head>
<title>quee.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
.newcolor {
background-color: red;
}
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function () {
$("div").click(function () {//没有点击,就没有执行下面的方法;其中$("div").queue就没有执行,所以无法获取特效方法队列
$("div").show("slow");//1运行
$("div").animate({left:'+=200'},2000);//2运行
$("div").queue(function () {//3运行
//alert(this.innerHTML);
$(this).addClass("newcolor");//为所有div的newcolor样式
$(this).dequeue();//4执行这个方法,就会移除队列中第一个特效函数$(this).show("slow");//1运行
//并执行这个特效
});
$("div").animate({left:'-=200'},500);//5运行
$("div").queue(function () {//6运行
//alert(this.innerHTML);
$(this).removeClass("newcolor");//删除newcolor
$(this).dequeue();//7运行,//2运行,并移除2$(this).animate({left:'+=200'},2000);
});
$("div").slideUp();
});
});
</script> </head>
<body>
<div>abc</div>
</body>
</html>