【发布时间】:2019-04-20 11:31:34
【问题描述】:
我必须在移动设备上三次点击我的网站正文时显示和隐藏一个 div 我用 JavaScript 编写的以下代码在 android 设备中运行良好,但在 IOS 中不起作用。 所以你能帮我解决它吗?
代码是:
window.onload = function() {
document.querySelector('body').addEventListener('click', function(evt) {
evt.preventDefault();
if (evt.detail === 3) {
document.getElementById('mmu').style.height = '100px';
}
if (evt.detail === 1) {
document.getElementById('mmu').style.height = '0px';
}
});
}
#mmu {
width: 100px;
height: 0px;
position: fixed;
left: 0;
cursor: pointer;
top: 0;
background: red;
}
body {
height: 1000px;
background: #eee;
width: 100%;
cursor: pointer;
}
<div id="mmu"></div>
【问题讨论】:
-
evt.detail返回什么? -
@AswinKumar 它在桌面和安卓设备上运行良好。 evt.detail 返回用户点击次数
标签: javascript jquery ios click