abstrak:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>改變DIV樣式</title><style type="text/css">#div1{height: 200px;width: 200px;background:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>改變DIV樣式</title> <style type="text/css"> #div1{height: 200px;width: 200px;background: red;margin: 20px 50px;} </style> </head> <body> <div id="div1"></div> <input type="button" value="變高" onclick="aa()"> <input type="button" value="變寬" onclick="bb()"> <input type="button" value="變色" onclick="cc()"> <input type="button" value="重置" onclick="dd()"> <input type="button" value="隱藏" onclick="ee()"> <input type="button" value="顯示" onclick="ff()"> <script type="text/javascript"> var div1 window.onload=function () { div1=document.getElementById('div1'); } function aa() { div1.style.height="450px"; } function bb() { div1.style.width="400px"; } function cc() { div1.style.background="#ccc"; } function dd() { div1.style.height="200px"; div1.style.width="200px"; div1.style.background="red"; } function ee() { div1.style.display="none"; } function ff() { div1.style.display="block"; } </script> </body> </html>
Guru membetulkan:韋小寶Masa pembetulan:2018-11-27 09:02:32
Rumusan guru:嗯!寫的很不錯!課后別忘了要多多練習哦!