Why when I click inside the box with the black border, the toggle doesn't execute but when I click outside, it does, but not the checkbox?
var checks = document.querySelectorAll("ul li");
for (var i = 0; i < checks.length; i++) {
checks[i].addEventListener("click", tog);
};
function tog(e) {
e.currentTarget.classList.toggle("active");
}
ul li {
background: #3CF;
padding: 0.25em 0.5em;
margin: 0.25em 0;
display: block;
cursor: pointer;
text-indent: 1.5em;
}
ul li.active {
background: #6EF;
}
label {
display: block;
width: 100px;
border: 1px solid black;
}
<ul>
<li>
<label>
<input type="checkbox">1
</label>
</li>
<li>
<label>
<input type="checkbox">2
</label>
</li>
<li>
<label>
<input type="checkbox">3
</label>
</li>
</ul>