摘要:<!DOCTYPE html><html><head> <title>ccccccc</title> <meta charset="utf-8"> <style type="text/css"> #box{height: 100px;width: 100px;backgrou
<!DOCTYPE html>
<html>
<head>
<title>ccccccc</title>
<meta charset="utf-8">
<style type="text/css">
#box{height: 100px;width: 100px;background: red;}//聲明div中idBOX的樣式
</style>
<body>
<div id="box"></div>
<input type="button" value="變高" onclick="gao()">//通過onclick事件觸發(fā)并引用函數(shù)實(shí)現(xiàn)效果
<input type="button" value="變寬" onclick="kuan()">
<input type="button" value="變色" onclick="se()">
<input type="button" value="隱藏"onclick="yin()">
<input type="button" value="顯示"onclick="xian()">
<input type="button" value="重置"onclick="chongz()">
<script type="text/javascript">
var box //聲明box引用以下全局變量
window.onload=function(){
box=document.getElementById("box")
}
function gao(){
box.style.height="300px"
}
function kuan(){
box.style.width="250px"
}
function se(){
box.style.background="pink"
}
function chongz(){
box.style.height="100px"
box.style.width="100px"
box.style.background="red"
}
function yin(){
box.style.display="none"
}
function xian(){
box.style.display="block"
}
</script>
</body>
</html>
批改老師:滅絕師太批改時(shí)間:2019-01-12 09:17:30
老師總結(jié):完成的不錯(cuò)!作業(yè)是為了鞏固知識(shí)點(diǎn),確保知識(shí)點(diǎn)都有好好掌握哦!