I am trying to have an icon that switches class when the parent div is hovered. So far, here is my code:
var actionIcon = document.querySelector(".task > svg")
var taskContainer = document.querySelector(".task")
function iconScale() {
actionIcon.classList.toggle('big');
}
taskContainer.onmouseenter = iconScale
taskContainer.onmouseleave = iconScale
And the HTML:
<div class="task">
<h3>Title</h3>
<svg viewBox="0 0 24 24">
<path d="..." />
</svg>
</div>
My issue is that the effect I am trying to achieve is only happening on the very first parent element and none of the other ones. I'm pretty sure I am not specifying something but I don't know what. Anyone could give me a hint?