<!DOCTYPE html>
<html>
<headn charset="utf-8">
<title>jq事件</title>
<script type="text/javascript" src="css/jquery-3.4.1.min.js"></script>
<style type="text/css">
div,p{width: 200px;height: 200px;border: 1px solid #ccc;}
</style>
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
$('div').hover(
function(){
$(this).css('background','red')
},
function(){
$(this).css('color','#fff')
}
)
$('button').click(function(){
$('p').toggle().css('background','red')
})
})
</script>
<div>我是内容</div>
<p style="display: none;"></p>
<button>点击</button>
</body>
</html>