【发布时间】:2017-08-10 15:30:23
【问题描述】:
我在 jQuery 中使用了 fadeIn 和 fadeOut,它在桌面上运行良好。但是,在移动设备上(我只在 iPhone 上测试过),子 div 在触摸时打开,但在触摸外部元素后不会隐藏。我对 jQuery 相当陌生,所以我不太确定我可以在这里实现什么样的解决方案。也许移动检测并执行触摸以打开/隐藏,尽管我不知道如何做到这一点。这是我的 JSFiddle:
https://jsfiddle.net/9LL3mmzt/
jQuery:
$(document).ready(function() {
$(".parent").hover(function() {
$(this).children(".child").fadeIn("fast");
}, function() {
$(this).children(".child").fadeOut("fast");
});
});
HTML:
<div class="parent">
<span>Peek-A-</span>
<div class="child">
<span>Boo</span>
</div>
</div>
CSS:
.child {
display: none;
}
我尝试了这个帖子的第一个解决方案:time-out on jQuery hover function
但是,由于我的知识有限,我无法使其正常工作。
【问题讨论】:
标签: javascript jquery html css