I am trying to add a class to a child element when the user's mouse moves over the parent. I assumed I could do this by using 'firstChild' but I can't get this to work:
var hoverTrendingBoxContainer = document.querySelectorAll(".trending-box-container");
for (i = 0; i < hoverTrendingBoxContainer.length; i++) {
hoverTrendingBoxContainer[i].addEventListener("mouseover", function () {
this.firstChild.classList.add("trending-box-image-hover");
});
}
This returns 'Cannot read property 'add' of undefined'
Neil