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

varflag=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();});}

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