<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title> </title> <style type="text/css"> #div1{ width: 200px; height: 200px; background: red; display: none; } </style> <script type="text/javascript"> window.onload=function(){ var obtn1=document.getElementById("btn"); obtn1.onclick=function(){ var oDiv=document.getElementById("div1"); if(oDiv.style.display=="none"){ oDiv.style.display="block"; } else{ oDiv.style.display="none"; } } } </script> </head> <body> <input type="button" name="" id="btn" value="显示隐藏" /> <div id="div1"> </div> </body></html>
添加回答
举报
0/150
提交
取消