A method that imitates the hover event. When you move the cursor over a matched element, the specified first function hover ([over,] out) is triggered)
A method that imitates a hover event (move the mouse over an object and remove it)
When you move the cursor over a matching element, the specified first function is triggered.
When you move the cursor out of this element, the specified second function is triggered.
The Code is as follows:
$ ('. MyDiv'). hover (function (){
DoSomething...
}, Function (){
DoSomething...
});
The problem is that some elements, such as menus, are dynamically loaded using AJAX.
The menu has not been loaded yet, so we need to use another jquery method live ()
The. live () method is valid for an element that has not been added to the DOM because event delegation is used:
Event Handlers bound to the ancestor element can respond to events triggered on future generations.
The event handler function passed to. live () is not bound to an element,
Instead, it serves as a special event handler and binds it to the root node of the DOM tree.
The Code is as follows:
$ ('. MyDiv'). live ('hover ', function (event ){
If (event. type = 'mouseenter '){
DoSomething...
} Else {
DoSomething...
}
})
Some jquery versions respond to mouseenter and mouseleave
Some are mouseover and mouseout.
Waiting for research ......