When you click .menuButton
jquery will add a class named active
. This Jquery code works on Windows and on Android except on iOS (Tested with Chrome an
try this
$(document).ready(function() {
var $ua = navigator.userAgent;
var $event = ($ua.match(/(iPod|iPhone|iPad)/i)) ? "touchstart" : "click";
$(document).on($event, function(ev) {
if ($('.navmenu').hasClass('active')) {
$('.navmenu').toggleClass('active');
}
});
$('.menuButton').on('click', function(e) {
e.stopPropagation();
$('.navmenu').toggleClass('active');
});
});
http://codepen.io/fabiovaz/pen/VaPzqz
I really think your problems is $('html').click() on iOS, you can search other solutions (like touch actions) or check if this work $('html').click(function() { alert('hello world'); });
var ua = navigator.userAgent,
event = (ua.match(/iPad/i)) ? "touchstart" : "click";
$(document).on(event, function (ev) {
...
});