鋒利的JQuery一書中對toggle方法的講解停留在1.9版本以前,現在這個方法已經刪除了切換綁定事件的用途,于是我想嘗試一下幾種不同的替代方法:div:nth-of-type(1){width:200px;height:200px;background-color:aqua;float:left;display:block;}div:nth-of-type(2){width:200px;height:200px;background-color:tomato;margin-left:200px;}$(function(){$("#show-box").click(function(){if($("#show-box").css("display")=="block"){//is(":hidden")$(this).hide(300);}else{$(this).show(300);}});vari=0;$("#fade-box").click(function(){if(i==0){$(this).fadeOut(300);i=1;}elseif(i==1){$(this).fadeIn(300);i=0;}console.log(i);})})兩種方法都無法工作:都是只能消失而不能再次出現,想請問一下各位大佬是哪里出了問題...已經查閱了一些博文,用的也多是這兩種方法...
急求?。。?!JQuery toggle()方法替代問題大佬們有什么好的建議?
白衣非少年
2019-06-10 09:30:15