2013-10-15 138 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