下拉菜单

tech2022-08-06  86

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } a { display: block; height: 30px; width: 80px; border: 1px solid #666; } .box { height: 30px; width: 80px; } li { list-style: none; width: 80px; border: 1px solid #666; border-top: 0px; } </style> </head> <body> <div class="box"> <a href="#">下拉菜单</a> <ul style="display: none;"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> </div> <script> var box = document.querySelector(".box"); box.onmouseover = function () { this.children[1].style.display = "block"; } box.onmouseout = function () { this.children[1].style.display = "none"; } </script> </body> </html>

最新回复(0)