使用jQuery以纵向方向检测iPad

使用jQuery以纵向方向检测iPad,jquery,Jquery,我有一些jQuery,但只希望它在iPad处于纵向模式时运行,将iPad悬停在横向模式下处理脚本 var portraitWidth = $(window).width(); //detect the iPad in Portrait orientation if (portraitWidth < 769) { $('.model-selector h2:first-child').toggle(function () { $(this).p

我有一些jQuery,但只希望它在iPad处于纵向模式时运行,将iPad悬停在横向模式下处理脚本

var portraitWidth = $(window).width(); //detect the iPad in Portrait orientation
    if (portraitWidth < 769) {
        $('.model-selector h2:first-child').toggle(function () {
            $(this).parent().animate({
                top: '-138px'
            }, 250);
        }, function () {
            $('.model-selector').animate({
                top: '-45px'
            }, 250);
        });
    }
我做错了什么


提前谢谢。

我也有同样的问题。innerWidth对我来说是有效的,因为.width只测试设备的实际宽度,而实际宽度不变