<html> <head> <meta charset="utf-8"> <title>无标题文档</title> <style type="text/css"> #div1 { width: 100px; height:100px; background: red; display: none; } </style> <script> function showhide(){ var odiv=document.getElementById(‘div1‘); if(odiv.style.display==‘block‘) { odiv.style.display=‘none‘; } else{ odiv.style.display=‘block‘; } } </script> </head> <body> <input type="button" value="显示隐藏" onClick="showhide()" /> <div id="div1"> </div> </body> </html>
时间: 2024-10-13 03:17:51