Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

280
Views
Javascript click event doe not work on wordpress

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:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

querySelectorAll returns all elements in the document that matches the selector. You need to access the elements with an index:

document.querySelectorAll(".qsm_check_answer")[0]

Here is a link to more info on MDN.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!