A method that mimics a hover event that triggers the specified first function when the mouse moves over a matching element
Hover ([Over,]out) a method that mimics a hover event (the mouse moves over an object and moves it out) when the mouse moves to a matching element, the specified first function is triggered. When the mouse moves out of this element, the specified second function is triggered. Copy code code as follows: $ ('. Mydiv '). Hover (function () {dosomething ...}, function () {dosomething ...}); The problem is that some elements like menus are dynamically loaded through Ajax, when the hover method executes, the menu is not loaded yet, so another way to use jquery is Live (). The live () method works for an element that has not yet been added to the DOM because of the use of an event delegate: Event handlers that are bound to ancestor elements can respond to events that are triggered on a descendant. The event handler function passed to. Live () is not bound to the element, but rather as a special event handler, bound 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 mouseover and mouseout to be verified ...