jQuery - Div full Width and Height of viewport

jQuery - Div full Width and Height of viewport

jQuery - Div full Width/Height of viewport with jQuery

This handy piece of code allows you to create a full width/height div according to the viewport. The code also handles window resizing. Great for modal dialogs or popups.

// global vars
var winWidth = $(window).width();
var winHeight = $(window).height();
// set initial div height / width
$('div').css({
    'width': winWidth,
    'height': winHeight,
    });
// make sure div stays full width/height on resize
$(window).resize(function(){
    $('div').css({
        'width': winWidth,
        'height': winHeight,
        });
    });

Source: [http://www.jqueryrain.com/2013/03/div-full-widthheight-of-viewport-with-jquery/