I\'ve got a problem with window.resize . My code js/jquery is here
var x = $(window).width();
var y = $(window).height();
var z = $(\'#card\').height();
var a =
Your final two lines seem to be the problem here:
$(document).ready( updateBodySize() );
$(window).resize( updateBodySize() );
Should be:
$(document).ready( updateBodySize );
$(window).resize( updateBodySize );
Note the dropping of the ()
from updateBodySize
- your aim is to pass the function updateBodySize
to .ready
and .resize
, not its result. By call the function instead, what you're doing is passing the result of updateBodySize()
to the .ready
and .resize
functions, in effect:
$(document).ready( null );
$(window).resize( null );
Which, as you've noticed, does nothing except what updateBodySize()
does first (two) times you called it. Drop the ()
and it will be treated as the event handler you expect.
PS:
Unless you're using the first block of
var x = $(window).width();
var y = $(window).height();
var z = $('#card').height();
var a = z + 140;
var b = 1.78 * y;
var c = 1.78 * a;
before your function block, you can drop it, since you redefine those var inside the function, so it'll calculate them independantly any time it's called.