Hover ([over,] out)
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.
$ ('. 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.
$ ('. 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 ......