首页 > Web开发 > 详细

jQuery事件切换toggle不起作用的问题

时间:2015-11-27 17:22:03      阅读:262      评论:0      收藏:0      [点我收藏+]

jQuery事件切换toggle

下面是固定的一段代码

 

<input id="btn" type="button" value="点击" >

<script>

 $(function(){

                            $("#btn").toggle(function(){

                                     alert("aaa");

                            },function(){

                                     alert("bbbb");

                            });

</script>

 

 引入

<script src="http://cdn.staticfile.org/jquery/1.7.1/jquery.min.js"></script>运行时

技术分享

第一次点击

技术分享

第二次点击

技术分享

可以正常切换

 

 

 

<script src="http://cdn.staticfile.org/jquery/1.9.1/jquery.min.js"></script>

一运行

技术分享

按钮就逐渐消失

最后弹出

技术分享

 

经测试之后发现,1.9之后开始出现这个效果,1.9之前完全没有问题

 

toggle功能在1.9版本之后发生变化了。不再支持多个事件轮流切换。摘一段官网说明:

Note: This method signature was deprecated in jQuery 1.8 and removed in jQuery 1.9. jQuery also provides an animation method named .toggle() that toggles the visibility of elements. Whether the animation or the event method is fired depends on the set of arguments passed.

 

jQuery事件切换toggle不起作用的问题

原文:http://www.cnblogs.com/jianpingHuang/p/5000955.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!