Reputation: 23
How would I apply a resize event to this code, so it gets the new height of window if its changed
$(document).ready(function() {
$("#page").height($(window).height());
});
Upvotes: 2
Views: 1976
Reputation: 185
$("#page").click(function () {
showHeight("window", $(window).height());
});
Make sure its at the bottom of the page.
Upvotes: 0
Reputation: 105029
$(function() {
$(window).resize(function(){
$("#page").height($(this).height());
}).resize();
});
As you may see I've also shortened the $(document).ready(function(){})
by simply doing the $(function(){})
.
Upvotes: 4
Reputation: 12541
$(window).resize(function() {
$(document).ready(function() {
$("#page").height($(window).height());
});
});
Should work fine.
OR [better formatting]
function resizePage()
{
$(function() {
$("#page").height($(window).height());
});
}
$(window).resize(function() { resizePage(); });
Upvotes: 0