Last active
October 10, 2019 21:06
-
-
Save meetKowshik/af97c5eb3a8369e7b8417570deaaa6d8 to your computer and use it in GitHub Desktop.
Dropdown Activate in touch device (working for iphone X landscape mode, Ipad and Ipad pro)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).resize(function() { | |
if($(this).innerWidth() > 800 && $(this).innerWidth() < 1367) { | |
if(/Ipad/i.test(navigator.userAgent)) { | |
$('Paste the navigation selector here').on('click', function(e) { | |
if($(this).hasClass('special class whether this one has submenu or not')) { | |
return false; | |
} | |
}) | |
} else if (/Mobi/i.test(navigator.userAgent)) { | |
$('Paste the navigation selector here').on('click', function(e) { | |
if($(this).hasClass('special class whether this one has submenu or not')) { | |
return false; | |
} | |
}) | |
} | |
} else { | |
$('Paste the navigation selector here').on('click', function(e) { | |
if($(this).hasClass('special class whether this one has submenu or not')) { | |
return true; | |
} | |
}) | |
} | |
}) | |
if($(this).innerWidth() > 800 && $(this).innerWidth() < 1367) { | |
if(/Ipad/i.test(navigator.userAgent)) { | |
$('Paste the navigation selector here').on('click', function(e) { | |
if($(this).hasClass('special class whether this one has submenu or not')) { | |
return false; | |
} | |
}) | |
} else if (/Mobi/i.test(navigator.userAgent)) { | |
$('Paste the navigation selector here').on('click', function(e) { | |
if($(this).hasClass('special class whether this one has submenu or not')) { | |
return false; | |
} | |
}) | |
} | |
} else { | |
$('Paste the navigation selector here').on('click', function(e) { | |
if($(this).hasClass('special class whether this one has submenu or not')) { | |
return true; | |
} | |
}) | |
} | |
For Wordpress Site | |
Add a top level menu item for redirecting to the main page for touch device. Add a special class to control the show and hide | |
$(window).resize(function() { | |
if($(this).innerWidth() > 991 && $(this).innerWidth() < 1367) { | |
if(/Ipad/i.test(navigator.userAgent)) { | |
$('Special top level class').addClass('active'); | |
$('.menu-item a').on('click', function(e) { | |
if($(this).parent().hasClass('menu-item-has-children')) { | |
return false; | |
} | |
}) | |
} else if (/Mobi/i.test(navigator.userAgent)) { | |
$('Special top level class').addClass('active'); | |
$('.menu-item a').on('click', function(e) { | |
if($(this).parent().hasClass('menu-item-has-children')) { | |
return false; | |
} | |
}) | |
} | |
} else { | |
$('Special top level class').removeClass('active'); | |
$('.menu-item a').on('click', function(e) { | |
if($(this).parent().hasClass('menu-item-has-children')) { | |
return true; | |
} | |
}) | |
} | |
}); | |
if($(this).innerWidth() > 991 && $(this).innerWidth() < 1367) { | |
if(/Ipad/i.test(navigator.userAgent)) { | |
$('Special top level class').addClass('active'); | |
$('.menu-item a').on('click', function(e) { | |
if($(this).parent().hasClass('menu-item-has-children')) { | |
return false; | |
} | |
}) | |
} else if (/Mobi/i.test(navigator.userAgent)) { | |
$('Special top level class').addClass('active'); | |
$('.menu-item a').on('click', function(e) { | |
if($(this).parent().hasClass('menu-item-has-children')) { | |
return false; | |
} | |
}) | |
} | |
} else { | |
$('Special top level class').removeClass('active'); | |
$('.menu-item a').on('click', function(e) { | |
if($(this).parent().hasClass('menu-item-has-children')) { | |
return true; | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment