Disable link on first click from dropdown

Hello,

I’m trying to disable a link which contains a dropdown menu when user access the website via tablet devices, so, when users taps the link from the tablet:

-> The dropdown appears but the link is disabled, then on the second tap the link works.

I think that this is probably solved but I haven’t found nothing suitable yet, I’m working with this code from here which doesn’t work:

jQuery(document).ready(function ($) {

    $("li.taphover > a").on('touchstart', function (e) {
        'use strict'; //satisfy the code inspectors
        var link = $(this); //preselect the link
        if (link.hasClass('hover')) {
            return true;
        } else {
            link.addClass('hover');
            $('li.taphover > a').not(this).removeClass('hover');
            e.preventDefault();
            return false; //extra, and to make sure the function has consistent return points
        }
    });

});

Hello Kevin,

I didn’t tested this, but maybe try out this one:

jQuery(document).ready(function ($) {
	$("#mainnav ul li.menu-item-has-children a").on('click', function(event) {
		event.preventDefault();
	});
});

This prevents the a-tag within the li with the specific class from the first ul of mainnav to follow the link.

Did you also tried to write just a “#” into the link field from the backend menu editor?

Best regards,
WeAreOne

Hello,

It isn’t exactly what I was looking for. I want to disable only first click, so the second time users click (or tap) it works. But I found a solution here: http://osvaldas.info/drop-down-navigation-responsive-and-touch-friendly.

Best Regards,

Kevin.

Hello,

oh, I guess I didn’t read as careful as I should, but gread that you solved your issue and found a solution!

Best regards,
WeAreOne