问题
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() );
});
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.
In my full function: this stops it from hiding the div.over
element.
Opening it in Chrome it works as expected. However, it's not in pretty much everything else (Tested in: Edge, IE11 and Firefox).
回答1:
Okay so we've found out why it doesn't work the :hover
was removed from .is()
a while back.
Rather than changing this question to suit my findings I will ask another (saves confusion).
My New Question: Keep jQuery Appended Element Open When Hovering It
来源:https://stackoverflow.com/questions/46320025/jquery-jquery-created-element-ishover-only-seems-to-work-in-chrome