I am trying to use Javascript/jQuery to resize part of a website based on the height of the window.
My code is as follows:
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);
}
What am I doing wrong? It doesn’t seem to resize the section controlled by main-wrapper.
You have an error in your conditional statement
(h) ? h - 100. You have to provide a value for if(h)evaluates to false. The correct syntax is (cond ? exptrue : expfalse)