abstract:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>changeDIV</title><style>input{border: none;background: lightblue;border-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>changeDIV</title>
<style>
input{border: none;background: lightblue;border-radius: 5px;font-size: 15px;}
#box{width: 200px;height: 200px;background: red;
text-align: center;line-height: 200px;
font-size:20px;margin: 50px;}
</style>
</head>
<body>
<!-- 用按钮控制DIV的高度、宽度、颜色、重置、隐藏及显示。 -->
<script>
var box
window.onload=function(){
box=document.getElementById('box')
}
function changeHeight(){
box.style.height="400px" //改变高度
}
function changeWidth(){
box.style.width="400px" //改变宽度
}
function changeColor(){
box.style.background="blue" //改变颜色
}
function changeRadius(){
box.style.borderRadius="400px" //改变形状
}
function reset(){
box.style. height="200px" //重置
box.style. width="200px"
box.style. background="red"
box.style.borderRadius="0px"
}
function hide(){
box.style.display="none" //隐藏
}
function display(){
box.style.display="block" //显示
}
</script>
<input type="button" value="变高" onclick="changeHeight()">
<input type="button" value="变宽" onclick="changeWidth()">
<input type="button" value="变色" onclick="changeColor()">
<input type="button" value="变圆" onclick="changeRadius()">
<input type="button" value="重置" onclick="reset()">
<input type="button" value="隐藏" onclick="hide()">
<input type="button" value="显示" onclick="display()">
<div id="box">变化无常</div>
</body>
</html>
Correcting teacher:灭绝师太Correction time:2019-03-16 13:13:11
Teacher's summary:案例可以跳出老师上课代码,自己找案例练习哦!