D
D
Dimas1232014-04-21 11:15:28
iPhone
Dimas123, 2014-04-21 11:15:28

Why doesn't hover in the menu work on iphone?

This menu does not work on iphone designmodo.com/demo/css3megamenu . Pressing does not open submenus.

There is a solution on the internet:

<script type="text/javascript">
    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
        $('.nav li a').click(function () {});
    }
</script>

I tried to prescribe this code before the html menu, it did not help. Maybe I'm doing something wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Melnikov, 2014-04-21
@mlnkv

But how do you imagine hovering over an element in touch devices?
is it when the finger hovered a millimeter from the screen above the element?))
In touch devices there are touchstart, touchend, touchcancel, touchleave, touchmove.
docs

K
Konstantin Kitmanov, 2014-04-21
@k12th

Some incomplete solution was found on the Internet.
First, we need to add a class to the styles that will do the same thing as :hover. Secondly, on click (or better on ontouchend), remove this class from all nav li and add it where clicked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question