又学会了新知识,,这个功能在现在的导航特效上很常见!
梦神2018-11-23 01:19:17152<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="jquery-3.3.1.js"></script>
<style>
div,p{width: 100px; height: 40px;background: #272822; text-align: center;line-height: 40px; color: #fff;font-size: 22px; }
</style>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
$("div").hover(
function(){
$(this).css("background","#085486")},
function(){
$(this).css("background","#272822")
}
)
$("button").click(function(){
$("p").toggle();
})
})
</script>
<div>首页</div>
<p style="display:none"></p>
<button>点击按钮</button>
</body>
</html>