搜索

改变div属性

原创 2019-03-24 17:14:05 379
摘要:<!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>


批改老师:查无此人批改时间:2019-03-25 09:22:51
老师总结:完成的不错。下次把代码缩进下。继续加油。

发布手记

热门词条