$ is not defined error
I've been trying to add a script that adds a class (.img_ _item--hover) to an element (.img__item) when the wrapper (.box) of said element is hovered.
However, this error popped up in the browser, telling me that $ is undefined. I haven't been able to find a solution.
6 Replies
because its jQuery (you would need to load a version of it as well)
Or just convert it to JS 😉
that conversion would be something like this (untested):
but honestly, that's an incredibly cursed way of styling an item on hover
change the
img__item--hover
class to be img__item:hover
and CSS will do that for you and you don't need any javascriptOhh, I was trying to change the styling of
img__item
when box
is hovered. That's why I assumed I'd need to use JS
Also thank you so much!! I appreciate the help from both of younope no reason to use JS for a simple hover when we have
:hover
pseudo selector, agree with Jochem.oh, hm, then the selector is slightly different (if
img__item
is a child of box):
there's always such a simple solution, that I realize after all the more complicated solutions 🙈 . Thank you for your help and time b1mind and Jochem!!