2011-06-27 50 views
1

我有3個在我的佈局中顯示更多鏈接。他們必須觸發與內容相同的所有表格。所以當你點擊鏈接1時,它會顯示錶格,但是如果你點擊鏈接2,表格不會再被隱藏(只有當我點擊2次時)。jQuery show hide多個鏈接

我該如何解決這個問題?

我的代碼我現在有:

$(".starterlink").toggle(
    function(){ $(".starterinfo").fadeIn('fast'); }, 
    function(){ $(".starterinfo").fadeOut('fast'); } 
); 
+1

你想要做什麼? –

+0

我想顯示並隱藏其中的信息表。但該表可以通過頁面上的3個分離鏈接觸發。 – Maanstraat

回答

4

如果我正確理解你的問題,你爲什麼不這樣做:

$(".starterlink").click(function(){ $(".starterinfo").fadeToggle('fast'); }); 

更新時間:

下面的測試代碼對我來說工作得很好。

<a href="#" class="starterlink">Click me</a> 
<div class="starterinfo">This will fade in and out</div> 

<script type="text/javascript"> 
    $(".starterlink").click(function() { $(".starterinfo").fadeToggle('fast'); }); 
</script> 
1

toggle()函數沒有toggle(function, function)簽名。 IE不會將兩個函數作爲參數。

0

也許像

$("#link1").click(function(){ 
    $("#tableid").attr('visible', false); 
}); 

$("#link2").click(function(){ 
    $("#tableid").attr('visible', true); 
}); 
+0

這可以消除衰落。 – pimvdb