0

this code in css works fine:

#translatemenu134 ul ul li:nth-child(1){
    background-color:blue;
}

but when I use this code in java script:

var translateOption = document.querySelector("#translatemenu134 ul ul li:nth-child(1)");
translateOption.addEventListener("click", function(){
    document.getElementById("languagebar001").innerHTML = "<span style='font-size:16px'><i class='fal fa-globe'></i> EN</span>";
    });

I face to this error in console: "Cannot read property 'addEventListener' of null" is this because of that the page is still loading and it does not find the element or I have done something wrong in the code? thank you for your response in advance

yahya
  • 55
  • 6
  • "is this because of that the page is still loading and it does not find the element" — Probably, but there isn't enough context in the question t be certain. – Quentin Oct 22 '20 at 12:28

0 Answers0