jquery - 将 IPAD 与 JQuery 一起使用时更改类

标签 jquery html css lightbox

当用户使用 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/

相关文章:

javascript - Angular-ui 日历错误

javascript - 如何从嵌套数组中获取字段值?

css - OSX 上的 Safari 意外地呈现具有填充不透明度的 linearGradient

html - CSS设置div颜色,当diva :hover

javascript - 如何将事件处理程序存储在变量中并稍后将其绑定(bind)到对象?

jquery - 验证html中的选项卡式 Pane

javascript - 从下拉列表生成 .txt 文件

html - Bootstrap : How to prevent sidebar and main div from collapsing when resizing page?

使用 AngularJS 动画服务的 CSS 转换无法正常工作

javascript - Jquery 和 Wordpress : The image file never shows up?