点击按钮变换颜色

<!DOCTYPE html>
<!--suppress ALL -->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div {
            width: 200px;
            height: 400px;
            background-color: forestgreen;
        }
    </style>
</head>
<body>
<input type="button" value="点击" id="btn">
<div id="dv">
</div>
<script>
    document.getElementById("btn").onclick = function () {
        document.getElementById("dv").style.backgroundColor = "yellow";
    };

</script>

 

posted @ 2019-03-20 20:27  showTimehzy  阅读(1196)  评论(0编辑  收藏  举报