Closed zdimaz closed 4 years ago
Try using querySelectorAll
instead of querySelector
to get all the links. Also, I had to remove the !
from the href
on codesandbox.
https://codesandbox.io/s/elated-dewdney-fjuqx
Let me know if you have any questions.
var links = document.querySelectorAll(".js_lightbox");
for (var i = 0; i < links.length; i++) {
links[i].addEventListener("click", function(e) {
e.preventDefault()
BigPicture({
el: e.target,
ytSrc: e.target.getAttribute("ytSrc")
})
})
}