【问题标题】:Click event doesn't work in IE when element has an opacity of zero当元素的不透明度为零时,单击事件在 IE 中不起作用
【发布时间】:2013-03-31 15:57:42
【问题描述】:

我有一个元素,当我将鼠标悬停在上面时,它的不透明度设置为零,我还绑定了一个点击事件到这个链接,当点击它时执行一个动作,但是这个点击在 IE 中不起作用,只有其他浏览器。当 IE 中的不透明度为零时,我可以做些什么让它仍然可以点击?

谢谢!

$("a.hover").mouseenter(function() {

             $(this).animate({opacity:0});

        });


     $("a.hover").click(function(event) {

         event.preventDefault();
         //perform other stuff/// 
     });

【问题讨论】:

  • 将不透明度设置为 .01 怎么样?
  • 为什么不用CSS处理悬停效果?
  • 对我来说听起来不合逻辑。为什么用户应该点击一个不可见的元素?

标签: jquery internet-explorer click opacity


【解决方案1】:

请在背景中添加透明图片。

【讨论】:

  • 问题是它已经有背景了,这就是我将它淡出的原因。
【解决方案2】:

HTML:

<a href="#" class="hover">My Link</a>

CSS:

.hover {
    transition: opacity 0.3s;
}
.hover:hover {
    opacity: 0;
}

JS:

$("a.hover").click(function (event) {
    event.preventDefault();
    //perform other stuff/// 
});

在 Chrome、FF 和 IE 8 + 9 中运行良好

演示:http://fiddle.jshell.net/Pisi2012/BxHB7/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-07
    • 2011-05-25
    • 1970-01-01
    • 2012-11-05
    • 2012-04-01
    • 1970-01-01
    相关资源
    最近更新 更多