Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript ClassList in JS not working.. Reply To: ClassList in JS not working..

#250599
Shikkediel
Participant

The var txt is limited to the scope of the event listener, so it is an unknown value inside the loadClass function. Try like this, raising the scope:

var test = document.getElementById("icon"), txt;

test.addEventListener("click", function() {
    txt =

...