javascript - Jquery help me analyze what happened: mouseover/mouseout ok but not hover/unhover -


I am working on some code where I trigger the code on hover / unhover . Then I decided to trigger the same code on Focus / Blur . Generally with hover / unhuror , I can always type as no commas format. But this time when I was trying to add Focus / Blur then I had to use the bind and with the second part was to use this.bind Such as:

  $ .fn.gogogo = function (msg) {$ (this) .bind ("focus hover", function () {$ ("# screen") .html (msg) ) .show ();}); $ (This) .bind ("blur unhover", function () {$ ("# screen") .html (""). Hide ();}); }  

The problem was that whatever I did, I did not take hover / nonover / . I had to return to mouseover / mouseout Code hover / unhover vs mouseover / mouseout

  $ In addition to Fn.gogogo = function (code), the code is the same {$ (This) .bind ("mouseover focus", function () {$ ("# screen") .html (msg) .show ();}); $ (This) .bind ("mouseout blurred", function () {$ ("# screen") .html (""). Hide ();}); }  

I thought that the hover / unvover only mouseover / mountout was uniquely. How behaviors differ: Hover / NonHower breaks my code, while mouseover / mouseout is okay?

Thank you.

hover .

Hover method is a feature method that combines event handlers into mousecenter and mouseover events.

If you open the source of jQuery, you will see that the hover method is defined as such:

  hover: function (fnOver, FnOut) {Return to this Musicor (Funovers). Mouseleave (fnOut); },  

You should bind the mousecenter and mouseleave instead of the event.


Edit : The difference between mousecenter and mouseover is that the mousecenter (And mouseleave ) is not bubble. This means that if you bring the mouse to any element, you will get a mouseover event (which is probably not what it is You want), while you only see Mousecenter event if the mouse has entered the element itself, for example, see


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -