I am trying to modify an element when it gets hovered, at some point, I need to get all elements with class name "image", my issue is that while allElements has a value inside of the main function (the first alert shows the value), allElements doesn't have a value anymore when called from the anonymous function (it is undefined).
What's wrong here ?
function register() {
    var i = 0
    var allElements = document.getElementsByClassName("image")
    alert(allElements) // Has a value
    while (i < allElements.length) {
        allElements[i].addEventListener("mouseover", function() {
            var description = null
            var j = 0
            alert(allElements[i]) // Undefined
            while (j < allElements[i].children.length) {
                var child = allElements[i].children[j]
                description = child
                if (child.id == "description") {
                    break
                }
                j++;
            }
            description.style = "display: block"
        });
        i++
    }
}
Thank you
 
     
     
     
    