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/

4
  • 1
    This thread might be relevant
    – Stphane
    Commented Apr 11, 2014 at 15:00
  • Should work the same on FF as on IE
    – A. Wolff
    Commented Apr 11, 2014 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. Commented Apr 11, 2014 at 15:56
  • used a setTimeout, it worked fine. thank you!
    – danslap
    Commented Apr 11, 2014 at 16:33

1 Answer 1

1

just replace

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

by

if ($("#panel2:hover").length > 0){

Not the answer you're looking for? Browse other questions tagged or ask your own question.