Reputation: 153
I have a script in place that adjusts the height of a div whenever the window is resized, and it works great. How do I keep this functionality, but also set the size initially when the page is loaded?
Currently, the window had to be manually resized before the height is defined.
$(window).bind("resize", resizeWindow);
function resizeWindow( e ) {
var newWindowHeight = $(window).height()-207;
$("#sponsorscroll").css("height", newWindowHeight );
}
Thanks in advance :)
Upvotes: 1
Views: 3529
Reputation: 47687
Add load
to your events to listen for
$(window).on("resize load", resizeWindow);
Upvotes: 4