jquery - 单击时删除 jquery css

标签 jquery css

我的网站上有一张图片,每次我点击它时,它都会滑动打开一个包含 4 个链接的框。 图像以 0.6 不透明度开始,当您单击它以打开框时,不透明度变为 1。 但是我希望当您关闭框时,不透明度回到 0.6。

我的代码是:

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);
    });
});

希望你能帮帮我。

最好的问候, 马丁

最佳答案

只需添加一个 callback function在您的 fadeOut() 上,在动画完成后将不透明度设置回 0.6:

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

关于jquery - 单击时删除 jquery css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19378739/

相关文章:

javascript - 如何使用 jQuery 设置选择框的第一个选项?

jquery - 使用 jquery 从 gmaps 获取并解析 JSON 以查找坐标

javascript每9秒循环一次?

javascript - 如何使用 jquery 在 HTML Canvas 中的选定图像对象中添加渐变效果

javascript - JQuery:如何制作具有 flex 效果的 3D Joystick 图像?

javascript - 将文本从跨度内传递到弹出窗口

html - 单击后更改按钮属性的 Bootstrap CSS

javascript - 诊断浏览器差异和问题的工具

html - 我想在所有内容图像上应用 css class(bootstrap) .img-responsive

html - Outlook 2007 将 HTML 电子邮件中的链接样式更改为在发送到 Hotmail、Gmail 等时带有蓝色下划线。有任何修复吗?