2013-10-15 60 views
2

我在我的網站上有一個圖像,每次點擊它時,它會打開一個包含4個鏈接的框。 圖像從0.6不透明度開始,當您單擊它打開框時,獲取不透明度1. 但是,當您關閉該框時,不透明度會返回到0.6。刪除點擊jquery css

我的代碼是:

jQuery(document).ready(function() { 
    jQuery('.toggle_hide').hide(); 
    jQuery(".moduletable span").css('cursor', 'pointer').click(function() { 
     var $this = $(this); 
     $this.css({ 
      opacity: '1' 
     });   
     $('.toggle_hide').not($this.next("div")).fadeOut(300); 
     $this.next("div").slideToggle(300); 
    }); 
}); 

希望你能幫助我。

最好的問候, 馬丁

回答

1

只需用你的​​添加callback function設置不透明度回到0.6動畫完成後:

$('.toggle_hide').not($this.next("div")).fadeOut(300, function() { 
    $this.css({opacity:'0.6'}); 
}); 
+1

+1,雖然方法簽名是'淡出(持續時間,回撥)' –

+0

@RoryMcCrossan好喊! –

+0

嘿詹姆斯, 非常感謝您的協助。我已經嘗試添加回調函數到我的淡出,但現在它似乎跳過第一次點擊時的不透明度更改,因爲它仍然在0.6不透明度。 – user2882079