Bootstrap jquery toggle 無效的解決辦法

【問題】:其實這個jquery的toggle無效跟Bootstrap沒什麼關係,可是事情是醬紫的。最近在使用Bootstrap這個前端框架,發現:原來的jquery的事件切換toggle無效了,出現了初始化動畫隱藏起來了。前端

$(".left-title-otoc").toggle( 
		      function () {
				$(this).next().slideUp();
		      },
			  function () {
				$(this).next().slideDown();
		  	  }
	);

【結論】Bootstrap這個前端框架引用的是jquery 1.9版本,而jquery 1.9版本已經刪除了toggle事件切換功能。jquery

【解決辦法:用 if 判斷語句作。】前端框架

$('.left-title-otoc').click(function(){   
			         if($(this).next().is(":visible"))
			         {         
			             $(this).next().slideUp();
					  
			          }
				  else{       
				     $(this).next().slideDown(); 
					
				    };
		})

【複雜的事情簡單說,快速解決問題,是我博客的風格。感謝您的閱讀~】框架

相關文章
相關標籤/搜索