jquery中toggle事件最新版本移除之后的解决

来源:互联网 发布:定时继续 python 编辑:程序博客网 时间:2024/05/16 15:37

jquery在1.9版本中已经移除了toggle事件,所以之后的版本不能使用toggle事件了

其中的一种解决方法:使用flag标记来切换

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <script src="../jquery-3.0.0/jquery-3.0.0.js"></script>    <script>        $(function() {            var flag = 1;            $(".e").click(function() {                if (flag == 1) {                    $(this).next().hide();                    flag = 0;                } else {                    $(this).next().show();                    flag = 1;                }            });        })    </script></head><body>    <div id="panel">        <div class="e">什么事jquery</div>        <div class="content">            文件没有添加到版本控制,add to VCS一下        </div>    </div></body></html>
0 0