当用户使用 ipad 时,如何更改 a:link 上的类。
我正在使用滑出式灯箱来显示视频,但我希望灯箱在用户使用 iPad 时发生变化。
<a href="#" class="video">Watch</a>
例如 网页版
/* Video overlay */
// Hide on load
$('.video-player').hide();
// Show the video player
$('.video').click(function() {
$('.video-player').show('slow');
return false;
});
//Hide the video player
$('.close-video').click(function() {
$('.video-player').hide('slow');
return false;
})
IPAD版
/* Video overlay */
// Hide on load
$('.video-player').hide();
// Show the video player
$('.video').fancybox({
'content' : $('.video-player').html(),
'titlePosition' : 'inside',
'transitionIn' : 'none',
'transitionOut' : 'none',
'overlayColor' : '#fff',
'overlayOpacity' : 0,
'scrolling' : 'no',
'onComplete' : function(){
$('.pop-detail input.button, .pop-detail a').click(function(){
$.fancybox.close();
})
},
'onClosed' :function(){
}
});
//Hide the video player
$('.close-video').click(function() {
$('.video-player').hide();
return false;
})
感谢您的帮助。
最佳答案
这将设置一个名为 iPad 的变量,该变量在 iPad 上为 True,在其他地方为 False。
var iPad = navigator.userAgent.match(/iPad/i) != null;
您可以使用它来决定使用哪个代码路径运行
if (iPad) {
// iPad version
} else {
// Normal version
}
关于jquery - 将 IPAD 与 JQuery 一起使用时更改类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5537008/