改变div属性

Original 2019-03-24 17:14:05 314
abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><style type="text/css">#box{width:100px;height:100px;background:re

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style type="text/css">

#box{

width:100px;

height:100px;

background:red;

}

</style>

</head>

<body>

<div id="box"></div>

<button onclick="aa()">变高</button>

<button onclick="bb()">变宽</button>

<button onclick="cc()">变色</button>

<button onclick="dd()">重置</button>

<button onclick="ee()">隐藏</button>

<button onclick="ff()">显示</button>

<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="pink";

}

function dd(){

box.style.width="100px";

box.style.height="100px";

box.style.backgorund="red";

}

function ee(){

box.style.display="none";

}

function ff(){

box.style.display="block";

}

</script>

</body>

</html>


Correcting teacher:查无此人Correction time:2019-03-25 09:22:51
Teacher's summary:完成的不错。下次把代码缩进下。继续加油。

Release Notes

Popular Entries