使用带有JQuery的IPAD时更改类

Qbe*_*ssi 4 html css jquery lightbox

当用户使用ipad时,如何在:link上更改类.

我正在使用滑出式灯箱来显示视频,但我希望在用户使用ipad时更改灯箱.

<a href="#" class="video">Watch</a>
Run Code Online (Sandbox Code Playgroud)

例如 网络版

/* 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;
})
Run Code Online (Sandbox Code Playgroud)

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;
    })
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

Ric*_*haw 5

这将设置一个名为iPad的变量,在iPad上为True,在其他地方为False.

var iPad = navigator.userAgent.match(/iPad/i) != null;
Run Code Online (Sandbox Code Playgroud)

您可以使用它来决定使用哪个代码路径

if (iPad) {
    // iPad version
} else {
    // Normal version
}
Run Code Online (Sandbox Code Playgroud)