[javascript]
// 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,
});
});
[/javascript]
Try this one without any confusion…
$(document).ready(function() {
getWidthAndHeight();
});
// make sure div stays full width/height on resize
$(window).resize(function() {
getWidthAndHeight();
});
function getWidthAndHeight (){
var winWidth = $(window).width();
var winHeight = $(window).height();
$(‘div#wrap’).css({‘width’: winWidth,’height’: winHeight,});
}