以上文章为转载自http://blog.sina.com.cn/s/blog_50042fab0101c7a9.html

var flag=1;
    $(".selector").click(function(){
        if(flag==1){
            //执行方法;
            flag=0;
        }else{
            //执行方法;
            flag=1;
        }

或者外接函数,例如

toggle(objs) {
    $(objs).each(function(){
        if ($(this).is(':hidden')) $(this).show(); else $(this).hide();
    });
}

第一种方法也是开关 的很好的体现。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
相关资源
相似解决方案