예제
코드는 다음과 같습니다.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>事件</title> <style type="text/css"> div{ width:150px;height:150px;background:#f60; } </style> </head> <body> <div id="dv"></div><br> <input type="button" value="隐藏" onclick="bt()"> <input type="button" value="显示" onclick="bt1()"> <script type="text/javascript"> function bt(){ var div=document.getElementById("dv"); div.style.display="none"; } function bt1(){ var div=document.getElementById("dv"); div.style.display="block"; } </script> </body> </html>