Js dom operation Click current Show Click other Hidden?

Click the child class under the current checks to be displayed as none, then the other checks,class is hidden by none, and the reason why it is not directly hidden by the parent. The parent always has the style of display
.
<div class="checks">
    <div class="none"></div>
    <div class="none"></div>
    <div class="none"></div>
</div>
<div class="checks">
    <div class="none"></div>
    <div class="none"></div>
</div>

var g = document.getElementsByClassName("checks");
for(let i = 0;i<g.length;iPP) {
    let none = g[i].getElementsByClassName("none");
    g[i].onclick = function (e) {
        for (let j =0;j<none.length;jPP) {
            // if() {
            none[j].style.display = "block"
            // } else {
            //   none[j].className= "none"
            // }
        }
        e.stopPropagation();
    }
}
Mar.20,2021

you are right to click on the current div, to change the css attribute of the current div. But with this line of thinking, there is still something wrong with the code you write.

1. Get the element outside the loop, otherwise you will have to get
2 every time. The logic inside is wrong, so take a good look at it

.

however, there is still a better way to do this, that is, when you click on a div, add a class, to it instead of modifying its own properties


var g = document.getElementsByClassName('checks');
        
        function ads () {
            var noneFirst =  document.getElementsByClassName('none');
            for (let a = 0; a < noneFirst.length; aPP) {
                noneFirst[a].style.display = 'none'
            }
        }
        for(let i = 0;i<g.length;iPP) {
            g[i].onclick = function (e) {
                ads()
                var none = g[i].getElementsByClassName('none');
//                none.style.display = 'none'
                for (let j =0;j<none.length;jPP) {
                    none[j].style.display = 'block'
                }
                e.stopPropagation();
            }
        }
Menu