[英]Hover js function on iPad doesn't toggle
On desktop when hover a div
some overlay slides down, OKE. 在桌面上悬停
div
某些覆盖层会向下滑动,确定。
But on my iPad that works on touch, OKE, but no toggle
when touch again. 但是在我的iPad上可以触摸,OKE,但是再次触摸时没有
toggle
。
The overlay div is always visible after the first click. 第一次点击后,overlay div始终可见。
$('.side').hover(
function(){
$(this).find('.txt').slideDown(250); //.fadeIn(250)
},
function(){
$(this).find('.txt').slideUp(250); //.fadeOut(250)
}
);
I have a example here: http://jsfiddle.net/fourroses666/87011nkx/ 我在这里有一个例子: http : //jsfiddle.net/fourroses666/87011nkx/
Any idea how to fix this for ipad - toggle
function? 任何想法如何解决此问题的iPad-
toggle
功能?
You need to implement custom hover
functionality with touch events support. 您需要使用触摸事件支持来实现自定义
hover
功能。 Looks like something like this would be enough in this case: 在这种情况下,看起来像这样就足够了:
$('.side').on({
'mouseenter mouseleave touchstart': function(e) {
var $txt = $(this).find('.txt'),
type = e.type == 'mouseenter' || (e.type == 'touchstart' && !$txt.is(':visible'));
$txt[type ? 'slideDown' : 'slideUp'](250);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.