javascript - Why is this on('resize') event triggered at load and not on window resize? -
i have following code wrapped in $(document).ready(function(){});
:
var sizemapcontainer = function(n) { var w = $(window).innerheight(); var h = $('#sl-header-container').outerheight(); var f = $('.oev-form-container').outerheight(); var m = w - h - f; $('#map-container').outerheight(m); } sizemapcontainer(1); $(window).on('resize', sizemapcontainer(2));
why sizemapcontainer
gets called twice when page loads not when resize window?
you're calling function, not binding event function. should be:
$(window).on('resize', function() { sizemapcontainer(2); });
Comments
Post a Comment