Javascript hover需要双击才能在SafariIOS上工作
我有以下几点:Javascript hover需要双击才能在SafariIOS上工作,javascript,jquery,Javascript,Jquery,我有以下几点: $(".t-gallery a").hover( function () { $(this).append("<div class='cover'><i class='fa fa-search-plus'></i></div>"); }, function () { $('div', this).remove(".cover"); } ); $(“.t-g
$(".t-gallery a").hover(
function () {
$(this).append("<div class='cover'><i class='fa fa-search-plus'></i></div>");
},
function () {
$('div', this).remove(".cover");
}
);
$(“.t-gallery a”)。悬停(
函数(){
$(此)。追加(“”);
},
函数(){
$('div',this.)。移除(“.cover”);
}
);
基本上,它会在图像上添加一个封面(当从pc上悬停时),然后打开图库,问题是,如果用户在iPhone或iPad上使用Safari,使用这个js需要用户双击才能打开图库,我怎么可能解决这个问题 无法在没有定点设备(鼠标…)的设备上模拟
悬停
。您需要提供更好地支持手机/平板电脑的用户体验。。。您应该检查并使用它们:-)尝试以下方法:
$(".t-gallery a").hover(
function () {
$(this).append("<div class='cover'><i class='fa fa-search-plus'></i></div>");
},
function () {
$('div', this).remove(".cover");
}
).on('touchstart',function(){
$(this).trigger('click');
});
$(“.t-gallery a”)。悬停(
函数(){
$(此)。追加(“”);
},
函数(){
$('div',this.)。移除(“.cover”);
}
).on('touchstart',函数(){
$(this.trigger('click');
});
iOS没有指针,因此不能有悬停效果。代码中有多个语法错误$('div',this.)。移除('cover');实际上应该是$(this.find('.cover').remove();这不是不对的,它叫。同样的事情,.find()
使用.yeah我知道,这就是为什么我想替换.hover,但我不知道检测点击iOStry的正确语法:.on('touchstart',function(){$(this).trigger('click');})代码>