摘要:<head><style type="text/css">#box{width: 100px;height: 100px;background:bisque}</style></head><body><div id="box"></div>
<head>
<style type="text/css">
#box{width: 100px;height: 100px;background:bisque}
</style>
</head>
<body>
<div id="box"></div>
<input type="button" value="變高" onclick="Alterheight()">
<input type="button" value="變寬" onclick="Alterwidth()">
<input type="button" value="變色" onclick="Altercolor()">
<input type="button" value="重置" onclick="Reset()">
<input type="button" value="隱藏" onclick="Hide()">
<input type="button" value="顯示" onclick="Display()">
<script type="text/javascript">
var box
window.onload = function(){
box = document.getElementById('box')
}
function Alterheight(){
box.style.height = '500px'
}
function Alterwidth(){
box.style.width = "500px"
}
function Altercolor(){
box.style.background = "red";
}
function Reset(){
box.style.height="100px";
box.style.width="100px";
box.style.background="bisque";
}
function Hide(){
box.style.display="none"
}
function Display(){
box.style.display="block"
}
</script>
</body>
批改老師:查無(wú)此人批改時(shí)間:2019-02-15 09:19:22
老師總結(jié):完成的不錯(cuò)。js代碼,每行結(jié)束要加上 ; 號(hào)。要養(yǎng)成習(xí)慣,因?yàn)樯暇€的項(xiàng)目,需要把js文件壓縮,這樣用戶訪問(wèn)時(shí),請(qǐng)求的文件會(huì)小一些,速度快一些。繼續(xù)加油。