Hover over jQuery

This question is related to information. I am new to jquery. I am pretty experienced in HTML and CSS.

What is the difference between Hover and Mouseover in jQuery. Are they not activated when falling over an element.

+7
jquery html
source share
2 answers

The higher level hover () function - it is built to call functions to handle both the mouseenter event and the mouseleave event. This is very convenient for a user interface element that has a hang and a normal state (for example, a button.)

The mouseover () function is specifically associated with the mouseover event. This is best for situations where you only need to, when the mouse crossed the border with the element, and you don't care what happens if it leaves. It is also a call function when you want to trigger an event for an element.

EXPLANATION FROM: http://www.quora.com/jQuery/What-is-the-difference-between-the-hover-and-mouseover-functions

+6
source share

mouseover (): Fire events for children of this element.

hover (): Guidance actually works with mouseenter and mouseleave without being fired for children.

To achieve a hover effect, we need both mouseover and mouseout event

 $("element").mousover(function(){ //do something over }).mouseout(function() { //do something out }); 

whereas in hover () it is just a callback.

 $("element").hover( function () { //do something enter }, function () { //do something exit } ); 

From David Jones Experience :

In the project I worked on, I set up the container div to use the mouse and mouse that added some html tabs to the container. It was fine, but I found that using mouseover / mouseout means the added html disappearing when I tried to interact with it along with another jquery I had in place, which contradicted him.

In the end, my specific solution required me to use mouseenter and mouseleave with a live function, rather than using hover, because I was working with the generated html.

+9
source share

All Articles