hover() 方法规定当鼠标指针悬停在被选元素上时要运行的两个函数。
jQuery 1.7 版本前该方法触发 mouseenter 和 mouseleave 事件。
jQuery 1.8 版本后该方法触发 mouseover 和 mouseout 事件。
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <script type="text/javascript" src="js/jquery-3.1.1.min.js" ></script> <link rel="stylesheet" href="css/style.css" /> <title></title> <script> $(function(){ $(msg).hover( function(){ $(this).wrap("<h1>") ; } , function(){ $(this).unwrap() ; } ) ; }) ; </script> </head> <body> <p id="msg">Hello World !!!</p> </body> </html>