This question has already been answered:
Hello!
Help, please, solve the problem by JS. You need to pull the variable "chosenClass" with its value from the function to continue working with it.
Thank you in advance.
---- JS ----
(function(){ var elements = document.querySelectorAll('.items > span'); for (var i = 0; i < elements.length; i++){ elements[i].onclick = function(){ document.getElementById('userResult').innerHTML = this.innerHTML; var chosenClass = this.childNodes[0].classList[3]; } } })();