摘要:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title></title> <style type="text/css"> #box{width: 100px;height: 100px;background
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#box{width: 100px;height: 100px;background:red;margin:50px; }
</style>
</head>
<body>
<script type="text/javascript">
var box
window.onload = function(){
box = document.getElementById('box')
}
function gao(){
box.style.height = "200px"
}
function kuan(){
box.style.width = "200px"
}
function se(){
box.style.background = "pink"
}
function co(){
box.style.height = "100px"
box.style.width = "100px"
box.style.background = "red"
}
function yin(){
box.style.display = "none"
}
function xan(){
box.style.display = "block"
}
</script>
<div id="box">
</div>
<button onclick="gao()">變高</button>
<button onclick="kuan()">變寬</button>
<button onclick="se()">變色</button>
<button onclick="co()">重置</button>
<button onclick="yin()">隱藏</button>
<button onclick="xan()">顯示</button>
</body>
</html>
批改老師:天蓬老師批改時間:2018-12-12 16:20:16
老師總結:作業(yè)合格,在實際項目開發(fā)中,最好少用或者不用全局變量。