V
V
Vladimir2014-03-17 16:28:26
iOS
Vladimir, 2014-03-17 16:28:26

How to disable :hover on ipad?

I'm setting up a custom control in which you need to select the number of passengers. 4 people in a row, when you click on a person, it is added. When you hover, a plus sign / cross appears. The problem is that on the ipad hover is processed on click, so you have to click 2 times. I want to make it so that hover is ignored on the iPad and the click event occurs immediately.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Ineshin, 2014-03-17
@IonDen

1. Check for support for touch events
2. If it does, then use native events instead of mouse events (touchstart instead of click for example)

A
Alex Pro, 2014-03-18
@Stillborn

If I understand correctly, here is an example:

function is_touch_device() {
  return !!('ontouchstart' in window);
}

There is also an option to use modernizr which will put down the classes (.touch for example), and :hover is already attached to the classes of non-touch devices.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question