摘要:<!DOCTYPE html> <html> <head> <title>ChangeDIV</title> <style type="text/css"> #box{width: 100px;height: 100px;background: re
<!DOCTYPE html>
<html>
<head>
<title>ChangeDIV</title>
<style type="text/css">
#box{width: 100px;height: 100px;background: red;margin: 20px 80px;}
</style>
</head>
<body>
<div id="box"></div>
<input type="button" value="变高" onclick="high()">
<input type="button" value="变宽" onclick="wdth()">
<input type="button" value="变色" onclick="clor()">
<input type="button" value="重置" onclick="rest()">
<input type="button" value="隐藏" onclick="hid()">
<input type="button" value="显示" onclick="show()">
<script type="text/javascript">
var box
window.onload=function(){
box=document.getElementById('box')
}
function high () {
box.style.height="400px"
}
function wdth () {
box.style.width = '400px'
}
function clor () {
box.style.background = 'pink'
}
function rest () {
box.style.height = '100px'
box.style.width = '100px'
box.style.background = 'red'
}
function hid () {
box.style.display = 'none'
}
function show () {
box.style.display = 'block'
}
</script>
</body>
</html>
批改老师:灭绝师太批改时间:2018-12-14 13:13:48
老师总结:小案例比较简单,自己可以尝试一些其他案例,巩固学习奥!