1

I have this submenu that opens with mouseover, and all was good until I tested on firefox. Seems like this code doesnt work on IE nor firefox, is() isnt working. Any ideas?

this is my code:

$("#m4").mouseenter(function () {
  m4 = false;
  submenu(2)
});
$("#m4").mouseleave(function () {
  if ($("#panel2").is(':hover')) {
    m4 = false
  } else {
    m4 = true
  }
  submenu(2)
})
$("#panel2").mouseleave(function () {
  m4 = true;
  submenu(2)
});

http://jsfiddle.net/9PGh6/1/

Blazemonger
  • 90,923
  • 26
  • 142
  • 180
danslap
  • 23
  • 6
  • 1
    [This thread](http://stackoverflow.com/questions/8981463/detect-if-hovering-over-element-with-jquery) might be relevant – Stphane Apr 11 '14 at 15:00
  • Should work the same on FF as on IE – A. Wolff Apr 11 '14 at 15:10
  • 1
    I believe the problem is that the browser registers a mouseleave of `#m4` *before* you mouseenter `#panel2`, since they are not nested elements. You need to either nest them somehow, or introduce a `setTimeout` before your callback code is run. – Blazemonger Apr 11 '14 at 15:56
  • used a setTimeout, it worked fine. thank you! – danslap Apr 11 '14 at 16:33

1 Answers1

1

just replace

if ($("#panel2").is(':hover')) {

by

if ($("#panel2:hover").length > 0){
Someoneinthe
  • 372
  • 1
  • 9