????:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>changeDiv</title><style type="text/css">#box{width: 100px;height: 100px;background
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>changeDiv</title>
<style type="text/css">
#box{width: 100px;height: 100px;background: red;margin: 20px 100px;}
</style>
</head>
<body>
<div id="box"></div>
<input type="button" value="變高" onclick="H()">
<input type="button" value="變寬" onclick="W()">
<input type="button" value="變色" onclick="color()">
<input type="button" value="重置" onclick="reset()">
<input type="button" value="隱藏" onclick="hide()">
<input type="button" value="顯示" onclick="show()">
<script type="text/javascript">
var box
window.onload=function(){
box=document.getElementById('box')
}
function H(){
box.style.height="400px"
}
function W(){
box.style.width="400px"
}
function color(){
box.style.background="blue"
}
function reset(){
box.style.background="red"
box.style.height="100px"
box.style.width="100px"
}
function hide(){
box.style.display="none"
}
function show(){
box.style.display="block"
}
</script>
</body>
</html>
全局變量的引入:window.onload=function(){
}
?? ???:天蓬老師?? ??:2018-12-23 09:55:10
???? ??:全局變量收入的函數(shù)里面是空的,沒有實現(xiàn)還是忘記了?