<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .one{ background-color: lightcyan; width: 80px; height: 30px; border: 1px solid lightcyan; float: left; padding-bottom: 20px; margin: 5px; text-align: center; line-height: 30px; } .one:hover{ cursor: pointer; } .two{ background-color: blue; width: 1000px; } </style> </head> <body> <div id=""> <div class="one" onmouseover="aa(this)">栏目一</div> <div class="one" onmouseover="aa(this)">栏目二</div> <div class="one" onmouseover="aa(this)">栏目三</div> <div class="one" onmouseover="aa(this)">栏目四</div> <br /> <br /> <br /> <div class="two"> </div> </div> </body> </html> <script type="text/javascript"> function aa(a){ var two = document.getElementsByClassName("two")[0]; two.innerHTML = ""; for(var i = 0;i < 4; i++){ two.innerHTML += a.innerHTML + "的内容<br/>"; } } </script>
原文:https://www.cnblogs.com/yelena-niu/p/8858979.html