返回JS控制DIV......登陆

JS控制DIV样式

天腾²⁰¹⁹2019-03-16 11:54:57230

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>changeDIV</title>


<style>

input{border: none;background: lightblue;border-radius: 5px;font-size: 15px;}

#box{width: 200px;height: 200px;background: red;

text-align: center;line-height: 200px;

font-size:20px;margin: 50px;}




</style>

</head>

<body>

<!-- 用按钮控制DIV的高度、宽度、颜色、重置、隐藏及显示。 -->

<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="blue"  //改变颜色

}

function changeRadius(){

box.style.borderRadius="400px"  //改变形状

}

function reset(){

box.style. height="200px"  //重置

box.style. width="200px"

box.style. background="red"  

box.style.borderRadius="0px"

}

function hide(){

box.style.display="none"  //隐藏

}

function display(){

box.style.display="block"  //显示

}

</script>




<input type="button" value="变高" onclick="changeHeight()">

<input type="button" value="变宽" onclick="changeWidth()">

<input type="button" value="变色" onclick="changeColor()">

<input type="button" value="变圆" onclick="changeRadius()">

<input type="button" value="重置" onclick="reset()">

<input type="button" value="隐藏" onclick="hide()">

<input type="button" value="显示" onclick="display()">

<div id="box">变化无常</div>

</body>

</html>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送