Reputation: 169
Is it possible to have multiple events in jQuery, like this?
$(window).resize(function () {
$('#page-wrapper').css('height', (window.innerHeight - 51) + 'px');
});
Now it's just resize()
but is it possible to make it so that it is on both resize
and ready
?
$(window).resize.ready(function () {
$('#page-wrapper').css('height', (window.innerHeight - 51) + 'px');
});
Upvotes: 0
Views: 48
Reputation: 708126
Usually, this is done like this by just triggering a resize event when the document is ready which will then call your normal resize handler:
$(window).resize(function () {
$('#page-wrapper').css('height', (window.innerHeight - 51) + 'px');
});
$(document).ready(function() {
// trigger a resize event when the document is ready
$(window).resize();
});
See the third form of .resize()
in the jQuery doc. If it is called without any arguments, then it triggers the resize event so existing event handlers are called.
Upvotes: 1