摘要:<!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是页面加载完成后才会执行
批改老师:天蓬老师批改时间:2019-04-10 09:46:02
老师总结:你的函数命名, 是我喜欢的风格, 不错的, 就应该使用这种动名组合