Jquery if语句格式化



我有一个jquery if语句,它不太工作,我认为它很接近,但似乎不太想工作:

我希望它遵循以下内容:如果它是ios设备,我想让它做一件事,如果它是一个高度大于500px但小于830的窗口那就做另一件事如果这两件事都不是,那就做第三件事

var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);

if(agentID) {
    $("#about_container").css({
        height: $(window).height() + 500
    });
    $("#about_main_header_container").css({
        paddingBottom: (($(window).height() - $("#about_content_total").outerHeight(true)) /2) - 50
    });
    $("#services_wrapper").css({
        height: $(window).height() + 190
    });
    $("#services_main_header_container").css({
        paddingBottom: (($(window).height() - $("#services_container").outerHeight(true)) /2) - 10
    });
}
else if ($(window).height() > 500, $(window).height() < 830) {
$("#about_container").css({
    height: 830
});    
$("#services_wrapper").css({
    height: 830
});
$("#services_main_header_container").css({
    paddingBottom: 160
});
$("#about_main_header_container").css({
    paddingBottom: 130
});
}
else {
    $("#about_container").css({
        height: $(window).height() - 65
    });
    $("#about_main_header_container").css({
        paddingBottom: (($(window).height() - $("#about_content_total").outerHeight(true)) /2) - 175
    });
    $("#services_wrapper").css({
        height: $(window).height() - 100
    });
    $("#services_main_header_container").css({
        paddingBottom: (($(window).height() - $("#services_container").outerHeight(true)) /2) - 175
    });
}
else if ($(window).height() > 500, $(window).height() < 830)

不正确,它应该是:

else if ($(window).height() > 500 && $(window).height() < 830)

在javascript中,a,b只返回b

最新更新