返回javascr......登陆

javascript控制div样式

L2019-05-13 11:36:01196

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

46

47

48

49

50

51

52

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

    <title></title>

    <link rel="stylesheet" type="text/css" href="">

    <style type="text/css">

        div{

            width: 100px;

            height: 100px;

            border: 1px solid #000;

            margin: 30px;

        }

 

    </style>

</head>

<body>

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

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

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

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

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

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

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

<script type="text/javascript">

    var box;

    window.onload=function(){

        box=document.getElementById('box');

    }

    function he(){

        box.style.height='200px';

    }

    function wd(){

        box.style.width='200px';

    }

    function bg(){

        box.style.background='green';

    }

    function cz(){

        box.style.height='100px';

        box.style.width='100px';

        box.style.background='#fff';

    }

    function dn(){

        box.style.display='none';

    }

    function db(){

        box.style.display='block';

    }

</script>

</body>

</html>


最新手记推荐

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

全部回复(0)我要回复

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