2

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).

glenn223
  • 238
  • 1
  • 4
  • 16
  • I'm using jQuery 3.1.0, BTW – glenn223 Sep 20 '17 at 10:50
  • The fiddle works the same for me in Chrome and IE11 – Nope Sep 20 '17 at 10:56
  • @Fran. That's strange. Do mean both working or both not working? What version of IE are you running? I'm on Version: 11.608.15063.0 - Update Version: 11.0.46 – glenn223 Sep 20 '17 at 11:05
  • You mention in your post that the code behaves different in browsers other than Chrome. When Run your fiddle in Chrome or IE11.0.9600.18792 Update Version 11.0.46 it behaves in both browsers the exact same when hovering over the areas the time in the text is updated just the same. If that is right or not I have no idea but the behavior is identical. – Nope Sep 20 '17 at 11:24
  • So both say `TRUE`? The time update _(in the fiddle)_ is just so you know that the action is being performed. If so, then it may be your version if you're on `11.0.9600`. What do you think? **Bloody IE!** – glenn223 Sep 20 '17 at 11:30
  • AFAIK there is no `:hover` [selector](https://api.jquery.com/category/selectors/) is jQuery - how do you come by this idea ? [$.is()](https://api.jquery.com/is/) needs a selector. EDIT: nvm - you want the pure-css selector via jq – birdspider Sep 20 '17 at 12:02
  • @see: https://stackoverflow.com/a/8010298/2645347 – birdspider Sep 20 '17 at 12:06
  • @glenn223 OK, I'm an idiot. I looked at the time and never the true false. Sorry. IE works with `:hover` inline no problem, as in `someselector:hover` however, it always had issues with `.is()` Not sure how you can work around this if you don't have an actual string reference to the selector you could concatenate with `:hover` – Nope Sep 20 '17 at 13:14

1 Answers1

0

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

glenn223
  • 238
  • 1
  • 4
  • 16