标签:
HTML:
<!DOCTYPE >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style type="text/css">
* {
margin: 0px;
padding: 0;
font-family: "微软雅黑", "arial", " sans-serif";
font-size: 16px;
}
body {
margin: 20px;
}
</style>
<script type="text/javascript" src="js/jquery-2.2.2.min.js">
</script>
<script type="text/javascript">
$(function () {
$("h2").hover(
function () {
$("#content").show(1);
},
function () {
$("#content").hide(1);
}
)
});
</script>
</head>
<body>
<div id="container">
<h2 style="margin: 0px;width: 166px;height: 25px;border: 1px silver solid;">关于hover方法的作用</h2>
<div id="content" style="width: 300px;height: 150px;border: 1px solid red;padding: 10px;display: none;">
hover方法:当鼠标移动到元素上或者是移出元素时执行事件处理代码,hover方法实际上是对mouseenter和mouseleave事件的合并,用来模仿一种鼠标悬停的效果
</div>
</div>
</body>
</html>
result:
运行:
标签:
原文地址:http://www.cnblogs.com/theWayToAce/p/5497800.html