Hello,
I have a CSS hover that works on everything BUT touch screens…
The only solutions is to write JavaScript touchstart event function. Which I have written and works, but only works on the first img.
The document.query.Selector will only select the first class… what can I use to select all classes to be hovered over…? selectorAll does not work… you can only select one…
The other option I see is to write a line code for each image, but I know there has to be easier way, or somthing in JS that will select all classes - not just the 1st one or only one.
And remember, when you have a NodeList, it’s not actually an Array - it’s an “Array-like construct”. I often prefer to convert my NodeList to a true Array:
// the spread operator (...) inside the array brackets turns the NodeList to an Array!
let allTheElz = [...document.querySelectorAll('.els-with-this-class') ];
I don’t remember testing touch events. It might be that you have to set up an event listener for touchend as well to remove the class. You might also have to use preventDefault.