The solution is as follows:
First, determine whether the current node of the event, that is, whether jquery's currentTarget is included in the target, that is, the following extension $. containsNode.
Then, In the mouseover and mouseout events when hover is called, determine whether currentTarget is included in the target, that is, $. fn. fhover Extension
The following is the related code:
Copy codeThe Code is as follows:
$. ContainsNode = function (parentNode, childNode ){
If (parentNode. contains ){
Return parentNode! = ChildNode & parentNode. contains (childNode );
} Else {
Return !! (ParentNode. compareDocumentPosition (childNode) & 16 );
}
}
$. Fn. fhover = function (over, out ){
This. hover (function (e ){
If ().containsnode(e.tar get, e. currentTarget )){
Return;
}
Over. call (this, e );
}, Function (e ){
If ().containsnode(e.tar get, e. currentTarget )){
Return;
}
Out. call (this, e );
});
Return this;
}