此代码可在桌面上完美运行,但不能在移动设备上运行……我认为它与mouseup事件有关,但我不确定分辨率是多少。有想法吗?预先感谢!
$(document).mouseup(function (e) {
var container = new Array();
container.push($('#item_1'));
$.each(container, function(key, value) {
if (!$(value).is(e.target)
&& $(value).has(e.target).length === 0) {
$(value).hide();
const nav = document.getElementById('nav');
nav.classList.remove("active");
}
if (menubutton) {
menubutton.addEventListener('click', () => {
nav.classList.toggle('active');
});
}
});
});