Bootstrap

jQuery 鼠标移入移出事件切换

<!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).on({
					mouseover : function(){
						$(this).wrap("<h1>") ;
					} ,
					mouseout : function(){
						$(this).unwrap() ;
					} 
				}) ;
			}) ;  
		</script>
	</head>
	<body> 
		<p id="msg">Hello World !!!</p>
	</body>
</html>

hover() 方法规定当鼠标指针悬停在被选元素上时要运行的两个函数。

jQuery 1.7 版本前该方法触发 mouseentermouseleave 事件。

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>

 

;