html如何点击是按钮隐藏输入框,点击否显示输入框

我上来就是一手小demo

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box {
            height: 200px;
            width: 200px;
            border: red solid 2px;
        }

        .box1 {
            height: 50px;
            width: 50px;
            border: red solid 2px;
        }

        .box2 {
            height: 50px;
            width: 50px;
            float: right;
            top: -50px;
            position: relative;
            border: red solid 2px;
        }


    </style>
</head>

<body>
<div class="box">
    <div class="box1">
        <span></span>
        <input type="radio" name="c1" onclick="b_button()"/>
    </div>

    <div class="box2">
        <span></span>
        <input type="radio" name="c1" onclick="c_button()"/>
    </div>
    <div class="box3" id="yincang">
        <span style="display: block">需要隐藏的内容</span>
    </div>
    <div>
        <span>不需要隐藏</span>
    </div>

</div>
</div>

</body>
<script>
    function c_button() {
        document.getElementById("yincang").style.display = 'none';
    }

    function b_button() {
        document.getElementById("yincang").style.display = 'block';
    }
</script>
</html>

 

posted @ 2020-12-18 15:56  一只小泡沫  阅读(486)  评论(0)    收藏  举报