摘要:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">&
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JS控制DIV样式</title>
<style type="text/css">
#box{width: 100px;height: 100px;background-color: brown;margin: 20px 80px}
</style>
</head>
<body>
<div id="box"></div>
<input type="button" value="变高" onclick="aa()">
<input type="button" value="变宽" onclick="bb()">
<input type="button" value="变色" onclick="cc()">
<input type="button" value="重置" onclick="dd()">
<input type="button" value="隐藏" onclick="ee()">
<input type="button" value="显示" onclick="ff()">
<script type="text/javascript">
var box
window.onload=function(){
box=document.getElementById('box')
}
function aa(){
box.style.height="400px";
}
function bb(){
box.style.width="400px";
}
function cc(){
box.style.background="red";
}
function dd(){
box.style.height="100px";
box.style.width="100px";
box.style.background= brown}
function ee(){
box.style.display="none"
}
function ff(){
box.style.display="block"
}
</script>
</body>
</html>
批改老师:灭绝师太批改时间:2019-02-21 15:37:40
老师总结:案例可以自己拓展,不用一味测试老师测试代码哦!