我总是这样做,将最大的两个值分配给某些东西:
var targetHeight = (minHeight < $(window).height()) ? $(window).height() : minHeight;
我可以用不同的操作员做更整洁/更短/更棘手的事情吗?
很高兴有这样的东西:
// Use minHeight if it's greater than the window height.
var targetHeight = minHeight > $(window).height();
答案 0 :(得分:12)
您可以使用:
var targetHeight = Math.max(minHeight, $(window).height());