2
我有兩個或多個顯示某些內容的按鈕。這個想法是當我點擊按鈕.BB11
時顯示#Cont11
並隱藏#Cont11
當我點擊或當我點擊其他兩個按鈕時。其餘部分也是如此。我設法實現顯示/隱藏,當我點擊某個按鈕並單擊時,但窗口不隱藏,當我點擊另一個按鈕時,內容顯示。它需要在手機上工作。如何使用按鈕切換窗口並使用點擊消除
<div id="footer-menu">
<a class="BB11 BottomButton">Button1</a>
<a class="BB12 BottomButton">Button2</a>
<a class="BB13 BottomButton">Button3</a>
</div>
<div id="Content">
<div id="Cont11" class="ContIn">Some content</div>
<div id="Cont12" class="ContIn">Some content</div>
<div id="Cont13" class="ContIn">Some content</div>
</div>
的CSS:
.ContIn{display: none;}
JS:
$(".BB11").click(function(e){
$(".showing").fadeOut(300);
$("#Cont11").fadeIn(300); //toggle the window
$("#Cont11").toggleClass("showing");
$(this).toggleClass("highlighted");
e.stopPropagation(); //prevent event propagation
});
$(document).click(function(){
$("#Cont11").fadeOut(300); //hide the window
$("#Cont11").toggleClass("showing");
$(".BB11").removeClass("highlighted");
});
$("#Cont11").click(function(e){
e.stopPropagation();
});
/*------------------------------------*/
$(".BB12").click(function(e){
$(".showing").fadeOut(300);
$("#Cont12").fadeIn(300);
$("#Cont12").toggleClass("showing");
$(this).toggleClass("highlighted");
e.stopPropagation();
});
$(document).click(function(){
$("#Cont12").fadeOut(300);
$("#Cont12").toggleClass("showing");
$(".BB12").removeClass("highlighted");
});
$("#Cont12").click(function(e){
e.stopPropagation();
});
/*------------------------------------*/
$(".BB13").click(function(e){
$(".showing").fadeOut(300);
$("#Cont13").fadeIn(300);
$("#Cont13").toggleClass("showing");
$(this).toggleClass("highlighted");
e.stopPropagation();
});
$(document).click(function(){
$("#Cont13").fadeOut(300);
$("#Cont13").toggleClass("showing");
$(".BB13").removeClass("highlighted");
});
$("#Cont13").click(function(e){
e.stopPropagation();
});
這看起來太乾淨了! 男人我仍然喜歡編程:D – Qriyo
好吧,但它不適用於Android。經過Galaxy Ace 4測試。 – Qriyo
@Qriyo很高興你喜歡它。您是否使用了我爲您提供的相同代碼?還是你修改了一些東西?如果是這樣,請提交您的實際代碼。 :) – edd2110