js實現原生選項卡
阿新 • • 發佈:2018-11-22
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>開關按鈕設定</title> </head> <link rel="stylesheet" href="css/Default style sheet.css" /> <style> div{ width:120px; margin: 0px auto; border: 2px solid black;} ul{ display: none; } </style> <script> window.onload=function(){ var odiv=document.getElementById("v"); var oli=odiv.getElementsByTagName("ul")[0]; var onf=true odiv.onclick=function(){ if (onf==true) { oli.style.display='block'; onf=false } else{ oli.style.display='none'; onf=true } } } </script> <body> <div id="v"> <h4>你好啊,小老弟</h2> <ul> <li>come</li> <li>on</li> <li>do</li> </ul> </div> </body> </html>