返回js改变div......登陆

js改变div样式

Goshawk2018-12-03 11:22:49364

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

<!DOCTYPE html>

<html>

    <head>

        <meta charset="UTF-8">

        <title>js控制div样式</title>

        <style type="text/css">

            #box{

                width: 100px;

                height: 100px;

                background: red;

                margin: 20px 80px;

            }

        </style>

    </head>

    <body>

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

        <input type="button" name="" id="" value="改变高度" onclick="change(value)"/>

        <input type="button" name="" id="" value="改变宽度" onclick="change(value)"/>

        <input type="button" name="" id="" value="改变颜色" onclick="change(value)"/>

        <input type="button" name="" id="" value="重置" onclick="change(value)"/>

        <input type="button" name="" id="" value="隐藏" onclick="change(value)"/>

        <input type="button" name="" id="" value="显示" onclick="change(value)"/>

        <script type="text/javascript">

            var box=document.getElementById("box");

            function change (value) {

                if (value=="改变高度") {

                    box.style.height="400px";

                } else if(value=="改变宽度"){

                    box.style.width="400px";

                } else if (value=="改变颜色") {

                    box.style.backgroundColor="pink";

                } else if(value=="重置"){

                    box.style.height="100px";

                    box.style.width="100px";

                    box.style.background="red";

                } else if (value=="隐藏") {

                    box.style.display="none";

                } else if (value=="显示") {

                    box.style.display="block";

                }

            }

 

        </script>

    </body>

</html>


最新手记推荐

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

全部回复(0)我要回复

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