A little stuck here with the following code that works opening a modal on click with the class name '.pl-modal', however when using the class in multiple places it only works on the first element.
I'd like to understand why it doesn't work on multiple elements with the same class.
let player = null;
const $ = function (el) {
return document.querySelector(el);
};
$(document).on("click", function () {
$(".pl-modal").classList.add("pl-modal-active");
player.playVideo();
},false);
function popupClose() {
$(".pl-modal").classList.remove("pl-modal-active");
$(".pl-hidden").style.display = "block";
player.stopVideo();
player.setPlaybackRate(1);
}
window.onclick = function (event) {
if (event.target == $(".pl-modal")) {
popupClose();
}
};