用按钮控制div变化

原创 2019-01-31 14:29:37 205
摘要:<!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>Document</title>

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

<style>

#box{

width: 100px;

height: 100px;

background: pink;

border-radius:10px;

}

</style>

</head>

<body>

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

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

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

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

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

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

<button onclick="gg()">显示</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="green";

}

function ee(){

box.style.height="100px";

box.style.width="100px";

box.style.background="pink";

}

function ff(){

box.style.display="none";

}

function gg(){

box.style.display="block";

}


</script>

</body>

</html>


批改老师:灭绝师太批改时间:2019-01-31 14:34:10
老师总结:相对与直播课来说,vip的知识点相对来说比较细化,可以慢慢消化哦

发布手记

热门词条