I have a button inside a whole clickable div and I tried to add event.stopPropagation(); to the end of the button function, but the function itself is also being ignored.
What's wrong about the following code?
var mobileCaptionToggle = document.getElementsByClassName("mobile-caption-toggle");
var b;
for (b = 0; b < mobileCaptionToggle.length; b++) {
mobileCaptionToggle[b].addEventListener("click", function(event) {
var mobileCaptionOverlay = this.parentNode.children[0].children[0].children[0].children[0].children[1];
mobileCaptionOverlay.classList.toggle("visible");
mobileCaptionOverlay.addEventListener("click", function() {
mobileCaptionOverlay.classList.toggle("visible");
});
event.stopPropagation();
});
}