我正在尝试使用Javascript / jQuery根据窗口的高度调整网站的一部分。
我的代码如下:
jQuery.event.add(window, "load", resizeFrame);
jQuery.event.add(window, "resize", resizeFrame);
function resizeFrame()
{
var h = $(window).height();
$(".main-wrapper").css('height', (h) ? h - 100);
}
我做错了什么?它似乎没有调整main-wrapper控制的部分。
答案 0 :(得分:2)
条件语句(h) ? h - 100
中有错误。您必须为if (h)
求值为false的值提供值。正确的语法是(cond?exp true :exp false )
$(".main-wrapper").css('height', h ? h - 100 : default_value );