JavaScript控制DIV

Original 2018-12-10 16:43:21 263
abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>控制DIV</title> <style> /*设定DIV的初始值*/ #box{ width: 100px; height: 100
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>控制DIV</title>

<style>
/*设定DIV的初始值*/
#box{
width: 100px;
height: 100px;
background:  red;
margin: 20px 80px;
}

</style>
</head>

<body>

<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="pink"
}
function ReP() {
box.style.height="100px"
box.style.width="100px"
box.style.background="red"
}
function YC() {
box.style.display="none"

}
    function SPlay() {
box.style.display="block"

}

</script>

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

<input type="button" value="变高" onclick="ChangeHeight()">
<input type="button" value="变宽" onclick="ChangeWidth()">
<input type="button" value="变色" onclick="ChangeColor()">
<input type="button" value="重置" onclick="ReP()">
<input type="button" value="隐藏" onclick="YC()">
<input type="button" value="显示" onclick="SPlay()">


</body>
</html>


Correcting teacher:查无此人Correction time:2018-12-10 17:16:03
Teacher's summary:写的不错,不过我习惯js后面都有结束; 加油,少年

Release Notes

Popular Entries