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