摘要:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>完成自己想做的事</title>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>完成自己想做的事</title>
<style type="text/css">
#box{width: 200px;height: 200px;background: skyblue;margin: 40px 100px;}
</style>
</head>
<body>
<script type="text/javascript">
var box
window.onload=function (){
box=document.getElementById('box')
}
function aa() {
box.style.height="600px"
}
function bb() {
box.style.width="600px"
}
function cc() {
box.style.background="black"
}
function dd() {
box.style.height="200px"
box.style.width="200px"
box.style.background="pink"
function ee() {
box.style.display="none"
}
function ff() {
box.style.display="block"
}
</script>
<div id="box"></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()">
</body>
</html>
對(duì)于第一步,先去把box給整合后,這樣很方便。就算繼續(xù)添加其他按鈕,也讓頁(yè)面中的代碼量沒(méi)有看起來(lái)那么龐大。
批改老師:西門(mén)大官人批改時(shí)間:2019-02-17 09:55:39
老師總結(jié):作業(yè)寫(xiě)的很好,思路也很好。以后寫(xiě)js代碼的時(shí)候最好加一下分號(hào)