整体代码如下,直接复制即可
<html> <head> <title>的实例演示代码</title> <meta name="generator" content="editplus"> <meta name="author" content=""> <meta name="keywords" content=""> <meta name="description" content=""> <script> var zhi = '1'; function show_or_none(){ if(zhi =="1"){ document.getelementbyid('div1').style.display="none"; zhi = "2"; }else{ document.getelementbyid('div1').style.display="block"; zhi = "1"; } } </script> </head> <body> <div onclick="show_or_none();" style="background:pink;">导航(展开/关闭)</div> <div id="div1"> <p>首页1</p> <p>首页2</p> <p>首页3</p> </div> </body> </html>