Please tell me , is the task using JavaScript, find all the links with the class .button and perform an action on them (calling the modal window). querySelectorAll does not help , since classes seem to be in different DOM branches. How to be? Do you have any hacks or something that I really misunderstand?
html for example:
<header> <a href="" class="button"></a> </header> <main> <a href="" class="button"></a> <a href="" class="button"></a> <a href="" class="button"></a> </main> <footer> <a href="" class="button"></a> </footer> Js
var link=document.querySelector(".button"); var popup = document.querySelector(".modal-window"); var close = document.querySelector(".close-form"); link.addEventListener("click", function(event) { event.preventDefault(); popup.classList.add("modal-window-see"); }, false); close.addEventListener("click", function(event) { event.preventDefault(); popup.classList.remove("modal-window-see"); }, false);