请告诉我,挑战是使用JavaScript,找到类.button 的所有链接并对它们执行操作(调用模式窗口) querySelectorAll not help ,因为类显然与DOM不同。 该怎么办?有一些黑客还是我被误解的东西?
示例html:
<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);