Jquery .css('opacity','0')不工作 [英] Jquery .css('opacity', '0') not working

查看:418
本文介绍了Jquery .css('opacity','0')不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以我一直在尝试一些东西,但不能让它工作。

Ok, so I've been trying something out but cant make it to work.

基本上我有一堆< li> ;如果< code>,则会出现隐藏的< div class =overlay> li>

Basically I have a bunch of <li> that has a hidden <div class="overlay">in it that would appear if the <li> was clicked. No problem displaying it, but somehow I'm having troubles making it disappear.

Jsfiddle - http://jsfiddle.net/NP5YA/

Jsfiddle - http://jsfiddle.net/NP5YA/

任何人都可以帮助?

谢谢!

推荐答案

您需要防止事件buble的DOM树,因此使用 event.stopPropagation()

You need to prevent event buble up the DOM tree so use event.stopPropagation():

$('.close').click(function(e) {
    e.stopPropagation();
    $(this).parent().css('opacity','0');
    $(this).parent().css('z-index','-999');
});

更新小提琴

这篇关于Jquery .css('opacity','0')不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆