I need to call a function by clicking on some elements.
I have tried several ways but it seems that it does not want to fire. the element in question is generated by the "quiz master and survey" plugin on wordpress.
Anyone have any idea what the problem might be? Thanks in advance!
window.onload = function() {
document.querySelectorAll('.qsm_check_answer').addEventListener("click",function(e){
var correctInfo = document.querySelector('#correct-info');
correctInfo.classList.add("d-none");
});
};
OR
document.querySelectorAll(".qsm_check_answer").addEventListener("click", function () {
document.querySelector("#correct-info").style.display = "none";
});
OR
window.onload = function () {
var checkboxQ = document.querySelectorAll(".qsm_check_answer");
checkboxQ.onclick = function () {
var correctInfo = document.querySelector("#correct-info");
correctInfo.classList.add("d-none");
};
};
Screenshot of Dom:
