lundi 27 juin 2022

How to check/uncheck checkbox by clicking outside specific block?

So I have a div that appears/disappears on clicking checkbox.


    <input type="checkbox" id="btn">
    <div id="box"></div>

    #box {
        display: none;
        width: 100px;
        height: 100px;
    }

    #btn:checked + #box
        display: block;
    }

But I also want to add an option to close it by clicking anywhere outside this box. How can I do it?




Aucun commentaire:

Enregistrer un commentaire