JavaScript DOM操作案例点击按钮显示隐藏div优化后

<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        div {
            width: 300px;
            height: 300px;
            background-color: pink;
        }
    </style>
</head>
<body>
<input type="button" value="隐藏" />

<div ></div>
<script src="common.js"></script>
<script>
    //获取按钮元素,注册点击事件,添加事件处理函数
    my$("bt1").onclick = function () {
        //判断当前点击按钮的value值
        if (this.value == "隐藏") {
            my$("dv").style.display = "none";
            this.value = "显示";
        } else if (this.value == "显示") {
            my$("dv").style.display = "block";
            this.value = "隐藏";
        }
    };
</script>
</body>
</html>