- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Avoid href on first click
Hi,
I don“t undersand JS and if anyone help me with this I apreciate.
I have a menu with hover to the sub-menu, but all the parent have href. What I need is in mobile is to avoid in the first click goes directly to href url.
My menu is something like this: https://codepen.io/Vulkanus/pen/yPKyeP
Thank you in advance
You could handle the click event on the anchors then and maybe check for something, an active class for example, and when it matches the class active, do the click result, otherwise return false.
The default handling of href isn’t done by javascript by the way.
Have you considered changing your menu markup so the parent buttons aren’t linked? You could repeat the parent button/link as the first item in a sub-menu. More info + ‘sticky hover’ fix here: https://css-tricks.com/forums/topic/hover-ios-vs-android/
I’ve come across a script called “DoubleTapToGo” that does something like JeroenR mentioned. That might offer a drop-in solution, but I’d personally opt for a menu restructure.
Hi @Beverleyh and @JeroenR
Thank you for your reply.
After I post this issue, I have also find the js “DoubleTabToGo” and I have tested, and works. But I will see the “hover-ios-vs-android” post and I will examine the possibility of amending or restructuring my menu.
Thank you both.