Home › Forums › JavaScript › ClassList in JS not working.. › Reply To: ClassList in JS not working..
January 27, 2017 at 9:27 am
#250599
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 =
...