<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="">
<script src=""></script>
</head>
<style>
* {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
.box {
width: 300px;
}
.box li {
width: 25%;
height: 30px;
text-align: center;
line-height: 30px;
float: left;
background-color: #6A8E24;
color: #fff;
}
.box li:hover {
background-color: #7F7F02;
}
div {
width: 300px;
height: 300px;
color: #fff;
line-height: 300px;
font-size: 30px;
display: none;
text-align: center;
background-color: #7F7F02;
}
.div1 {
display: block;
}
</style>
<body>
<ul class="box">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
<div>内容1</div>
<div>内容2</div>
<div>内容3</div>
<div>内容4</div>
</body>
<script>
var lis = document.querySelectorAll('li');
var divs = document.querySelectorAll('div')
for (let i = 0; i < 4; i++) {
lis[i].onmouseover = function() {
for (m = 0; m < 4; m++) {
divs[m].className = '';
}
divs[i].className = 'div1'
}
}
</script>
</html>