screenshots.gif

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            width:200px;
            height:200px;
            background-color:pink;

        }

        .hide{
            display:none;

        }

        .show{
            display:block;
    }

    </style>
</head>
<body>

<input type="button" value="点击隐藏" id="btn">

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

<script>
    var btn = document.getElementById("btn");
    var box = document.getElementById("box");

    btn.onclick = function(){
        if(btn.value === "点击隐藏"){

        box.className = "hide";
        btn.value = "点击显示";

        }else{
            
        box.className = "show";
        btn.value = "点击隐藏";
        }
    }





</script>

</body>
</html>