http://www.dewen.net.cn/q/16042/jquery fadeIn和fadeOut问题
2016-03-10 15:26
423 查看
http://www.dewen.net.cn/q/16042/jquery fadeIn和fadeOut问题
Zhen
2 票
Zhen 29
<script type="text/javascript">
$(function() {
$('#2').fadeOut();
$('#3').bind('click',function(e){
$(this).parent().fadeOut().delay(800,function(){$('#2').fadeIn('slow');});
});
$('#4').bind('click',function(e){
$(this).parent().fadeOut().delay(800,function(){$('#1').fadeIn('slow');});
});
});
</script>
<div id="1">
<button id="3">fadeOut div1</button>
</div>
<div id="2">
<button id="4">fadeOut div2</button>
</div>
如代码,点击第1个按钮-->淡入第2个层,淡出第1个层
点击第2个按钮-->淡出第2个层,淡入第1个层
实际运行时,点击第2个按钮,第一个层并没有显示出来,是bug么?
评论 (0) • 举报 (0) • 分享 • 链接 • 2014-02-10
添加评论...
2个答案 票 数
brayden认证专家
1 票
brayden6562
你的js代码有问题. 注意看jquery.delay的文档, delay的定义为:
.delay( duration [, queueName ] )
Description: Set a timer to delay execution of subsequent items in the queue.
是延迟队列中的下一个事件的执行. 这里的队列是jquery里的队列, 默认为fx, the standard effects queue. 下面的代码是可以实现你的要求:
$(function() {
$('#2').fadeOut();
$('#3').bind('click',function(e){
$(this).parent().fadeOut().delay(800);
$('#2').fadeIn('slow');
});
$('#4').bind('click',function(e){
$(this).parent().fadeOut().delay(800);
$('#1').fadeIn('slow');
});
});
http://jsfiddle.net/WEY53/
Zhen
2 票
Zhen 29
<script type="text/javascript">
$(function() {
$('#2').fadeOut();
$('#3').bind('click',function(e){
$(this).parent().fadeOut().delay(800,function(){$('#2').fadeIn('slow');});
});
$('#4').bind('click',function(e){
$(this).parent().fadeOut().delay(800,function(){$('#1').fadeIn('slow');});
});
});
</script>
<div id="1">
<button id="3">fadeOut div1</button>
</div>
<div id="2">
<button id="4">fadeOut div2</button>
</div>
如代码,点击第1个按钮-->淡入第2个层,淡出第1个层
点击第2个按钮-->淡出第2个层,淡入第1个层
实际运行时,点击第2个按钮,第一个层并没有显示出来,是bug么?
评论 (0) • 举报 (0) • 分享 • 链接 • 2014-02-10
添加评论...
2个答案 票 数
brayden认证专家
1 票
brayden6562
你的js代码有问题. 注意看jquery.delay的文档, delay的定义为:
.delay( duration [, queueName ] )
Description: Set a timer to delay execution of subsequent items in the queue.
是延迟队列中的下一个事件的执行. 这里的队列是jquery里的队列, 默认为fx, the standard effects queue. 下面的代码是可以实现你的要求:
$(function() {
$('#2').fadeOut();
$('#3').bind('click',function(e){
$(this).parent().fadeOut().delay(800);
$('#2').fadeIn('slow');
});
$('#4').bind('click',function(e){
$(this).parent().fadeOut().delay(800);
$('#1').fadeIn('slow');
});
});
http://jsfiddle.net/WEY53/
相关文章推荐
- http://www.dewen.net.cn/q/17095/SQL:用一条SQL语句统计出符合条件的内容
- http://www.dewen.net.cn/q/16222/C++排序中的sort函数第三个参数的疑问
- TCP/IP协议 1 ----实验楼转
- http://www.dewen.net.cn/q/15720/这样的情况一个sql语句怎么写
- 打造平安城市精品视频监控网络
- 浅谈HTTP中Get与Post的区别
- 使用802.1X+FreeRadius+LDAP实现网络准入方案
- node.js基础模块http、网页分析工具cherrio实现爬虫
- 判断安卓设备是否连接网络
- http 500错误详细代码意义
- iOS开发网络篇—数据缓存
- 关于HttpClient(调用openstack rest接口失败)
- TCP三次握手,四次挥手的状态变化
- Unity: C# TCP Client Server TcpListener NetworkStream UDP
- 【Android】【xUtils3网络下载图片的简单操作】
- Bitnami-Redmine通过https远程连接svn
- 可扩展,兼容多种网络请求框架的方案!!!
- 统计Apache的并发请求数及其TCP连接状态
- [转] 详解http和https的作用与区别
- Apache JMeter HTTPS(S) Test Script Recorder