15

i have this little jquery code running on jquery 1.10.1, what i want to do is quite basically console log on hover events on hovering over li class dash_item, but it only works when i click the item, not on hover

CODE:

$(document).ready(function(){
    $('.dash_item').on({

       mouseenter: function(){
        console.log("im here");
      },

      mouseleave: function(){
        console.log("im out");
      }
    });
});

the jsfiddle is here http://jsfiddle.net/JQAw3/

4
  • 2
    It works on hover for me, using Chrome, what browser are you using? Commented Jun 26, 2013 at 18:42
  • im using chrome aswell, however i just tried on mozilla and it works, thats very weird Commented Jun 26, 2013 at 18:42
  • It works for me on firefox Commented Jun 26, 2013 at 18:42
  • You have gremlins in your computer, only explanation. Commented Jun 26, 2013 at 18:44

5 Answers 5

43

Seems to be a Google Chrome bug that can happen when you have a website open for a long time, including the Dev Tools.

I had the same problems, tried everything I could.

In the end, a simple browser restart helped.

Maybe it's also enough if you simply open the website in another tab.

Edit 2015-06-15: I encounter this problem every time I'm working on mouseenter and mouseleave in Chrome. For me, it's definitely enough to just close the tab and open the website in another.

Sign up to request clarification or add additional context in comments.

7 Comments

It doesn't appear to be enough to open in another tab. I had to kill the browser. Thank you!
Confirmed restart worked. Wasted an hour on this, but you probably saved me a day!
I'm sad to report this is still a problem as of the time of this post. Thanks, you saved me tons of time!
+1000. One year later, and I just stumbled upon this same bug (using Chromium on Ubuntu)! I lost a few hours trying to solve this as it stopped working just after some code changes and I thought the problem came from my code!!!! I closed the tab and opened the page again in a new tab and my code worked again. I almost never restart Chromium so I owe you a lot of debugging time!
I noticed this only happens for me when Chrome Responsive view is active. Command + Shift + M will deactivate and the hover works again.
|
1

No it doesn't - same problems with hover as mouseenter

I have had developer tools open for some time

Opened the page in firefox and it worked

Comments

0

You can try the jQuery hover() function. It takes a handlerIn and handlerOut.

4 Comments

The .hover() method binds handlers for both mouseenter and mouseleave events. You can use it to simply apply behavior to an element during the time the mouse is within the element. In other words, there's no difference.
I know but it is an easier function to add imo.
@CWitty then it should be a comment, not an answer :)
Sorry new to stackoverflow.
0

works fine with hover

http://jsfiddle.net/blackjim/JQAw3/4/

$('.dash_item').hover(
    function () {
        console.log("im here");
    },
    function () {
        console.log("im out");
    }
);

2 Comments

As with CWitty's answer, hover is just shorthand for mouseenter and mouseleave.
Yeah I agree, but it's less code. Since he wants to handle both cases here.
0

Leaving this here in case anyone else stumbles across this. In early 2015 this is still a 'feature' in chrome/chromium where if the page is being viewed as a file (NOT served from a webserver) the mouse position events like mouseenter, mouseleave, mouseover, etc do not fire. Don't know if that was OP's issue but was mine when I stumbled across this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.