jQuery` [jQuery created Element] .is(":hover")`似乎只能在Chrome中运行 [英] jQuery `[jQuery created Element].is(":hover")` Only Seems To Work In Chrome

查看:57
本文介绍了jQuery` [jQuery created Element] .is(":hover")`似乎只能在Chrome中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅下面的代码(非常剥离,而不是我的全部功能)。我也有一个小提琴你可以在以下地方测试: https://jsfiddle.net/glenn2223 / uk7e7rwe / 1 /

Please see the code below (very stripped back and not my full function). I've also got a fiddle that you can test it at: https://jsfiddle.net/glenn2223/uk7e7rwe/1/

var 
    hov = $("<div class=\"over\">I'm Over You</div>"),
    box = $("<div>Result: WAITING</div>")


$("body").append(hov).append(box);

$("#MeHover").on('mouseleave', function(){
    var d = new Date();
    box.text("Result: " + hov.is(":hover").toString().toUpperCase() );
});

我们有 div div.over 稍微重叠一下。当您从 div 移动到 div.over 时,我希望该函数返回true。

We have a div and div.over overlaps it slightly. When you move from div to div.over I want the function to return true.

在我的完整功能中:这会阻止它隐藏 div.over 元素。

在Chrome中打开它可以正常工作。然而,它并不是其他所有东西(测试中:Edge,IE11和Firefox)。

Opening it in Chrome it works as expected. However, it's not in pretty much everything else (Tested in: Edge, IE11 and Firefox).

推荐答案

好的我们已经发现为什么它不起作用:hover 已经从 .is()中删除​​了一段时间。

Okay so we've found out why it doesn't work the :hover was removed from .is() a while back.

我不会改变这个问题以适应我的发现,而是会问另一个问题(节省混淆)。



我的新问题: 保持jQuery 附加悬停时元素打开


My New Question: Keep jQuery Appended Element Open When Hovering It

这篇关于jQuery` [jQuery created Element] .is(&quot;:hover&quot;)`似乎只能在Chrome中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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