返回通过按钮控制D......登陆

通过按钮控制DIV样式

2019-05-03 21:44:02243
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>改变DIV样式</title>
    <script>
    // 声明全局变量,让后面函数共同调用
        var box1
        window.onload=function(){
            box1 =document.getElementById('box');
        };
        // 去调用全局变量
        function one() {
            box1.style.height='300px';
        };
        function two() {
           box1.style.width='300px';
        };
        function there() {
            box1.style.background='lightpink';
        };
        function four() {
            box1.style.width='150px';
            box1.style.height='150px';
            box1.style.background='lightskyblue';
        };
        function five() {
            box1.style.display='none';
        };
        function six() {
            box1.style.display='block';
        }
    </script>
    <style>
        #box{width: 150px;height: 150px;background: lightskyblue;margin:10px 60px}
    </style>
</head>
<body>
    <div id="box"></div>
    <button onclick="one()">变高</button>
    <button onclick="two()">变宽</button>
    <button onclick="there()">变色</button>
    <button onclick="four()">重置</button>
    <button onclick="five()">隐藏</button>
    <button onclick="six()">显示</button>
</body>
</html>


最新手记推荐

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

全部回复(0)我要回复

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