jquery 1.9里面已经删除了toggle(fn1, fn2)函数:
引用
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.
要用的话可以引用1.9以下的jquery,或者写一个替代
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();
});
}