我已经按照我想要的方式进行了设置,结果发现,当我使用ipad时,我必须触摸链接两次才能激活它。
jQuery(document).ready(function () {
jQuery('.normal-model').live('mouseover', function () {
jQuery(this).find('.desc-box').fadeIn('slow');
var videoid = jQuery(this).find('.model-video a').attr('id');
var viddestin = jQuery(this).find('.model-video');
var postoi = jQuery(this).find('.model-video iframe');
if (postoi.length == 0) {
if (videoid != '' || videoid != ' ') {
var genifr = '<iframe src="http://www.youtube.com/embed/' + videoid + '?autoplay=1" frameborder="0" width="230" height="150"></iframe>';
}
jQuery(genifr).appendTo(viddestin);
}
});
jQuery('.normal-model').live('mouseleave', function () {
jQuery(this).find('.desc-box').fadeOut('slow');
jQuery(this).find('.model-video iframe').remove();
});
});如何让它在iPad上只被点击一次?
发布于 2013-03-11 23:38:34
iPads没有mouseover或mouseleave事件。尝试在mouse事件之外使用touchstart和touchend (或仅使用touch) (还要知道,为了支持.on,.live已被弃用):
jQuery('.normal-model').on('mouseover touch', function () {
// ...
jQuery('.normal-model').on('mouseleave touch', function () {发布于 2013-03-11 23:38:59
您正在将mouseover事件绑定到元素。由于触摸设备没有常规的悬停事件,因此它们通过确保在点击元素时将其视为悬停事件来解决此问题。第二次轻敲(doubleclick)激活正常的单击事件。
如果你想在你的iPad上提供良好的体验,就不要使用悬停事件来进行这种导航。只需将绑定更改为单击事件。
https://stackoverflow.com/questions/15342397
复制相似问题