点一下,让图片变得更大

<head>
    <meta charset="UTF-8">
    <title>Document</title>

    <style type="text/css">
        #box{
            width: 200px;
            height: 200px;
            background-color: red;
        }
    </style>
    <script type="text/javascript">
        window.onload=function(){
            document.getElementById("btn").onclick=function(){
            document.getElementById("box").style.width="400px";
            document.getElementById("box").style.height="400px";
        }
        }
    </script>
</head>
<body>
    <input type="button" name="btn" id="btn" value="确认">
    <div id="box"></div>
</body>

在这里插入图片描述
点击确认
在这里插入图片描述
先画出图片,再用onload函数,你点不点,点了我就变大,
当然有个触发事件的按钮

猜你喜欢

转载自blog.csdn.net/weixin_43560272/article/details/88963189
今日推荐