abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> #box{ height: 100
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> #box{ height: 100px; width: 100px; background: red; } </style> </head> <body> <div id="box"></div> <input type="button" value="高度" onclick="edit_height()"> <input type="button" value="寬度" onclick="edit_width()"> <input type="button" value="顏色" onclick="edit_background()"> <input type="button" value="還原" onclick="edit_res()"> <input type="button" value="隱藏" onclick="edit_hide()"> <input type="button" value="顯示" onclick="edit_show()"> <script type="text/javascript"> var box window.onload=function(){ box=document.getElementById('box') } function edit_height(){ box.style.height="200px" } function edit_width(){ box.style.width="200px" } function edit_background(){ box.style.background="blue" } function edit_res(){ box.style.height="100px" box.style.width="100px" box.style.background="red" } function edit_hide(){ box.style.display="none" } function edit_show(){ box.style.display="block" } </script> </body> </html>
屬性后面沒有分號
window.onload是頁面加載完成后才會執(zhí)行
Correcting teacher:天蓬老師Correction time:2019-04-10 09:46:02
Teacher's summary:你的函數(shù)命名, 是我喜歡的風格, 不錯的, 就應該使用這種動名組合