Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

jQuery: Combine document ready and window resize functions

$(document).ready(function() {
 alert('Document Loaded or Window Resized')
});

$(window).resize(function () {
 alert('Document Loaded or Window Resized')
});

Open in new window


Is there a good way to combine these two functions into one function? Something like this?


$(document).ready.OR.$(window).resize (function() {
 alert('Document Loaded or Window Resized')
});

Open in new window

SOLUTION
Avatar of Kiran Sonawane
Kiran Sonawane
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could also use a named function like this:
function loadAndResizeEvents() {
 alert('Document Loaded or Window Resized')
}

$(document).ready(loadAndResizeEvents);

$(window).resize(loadAndResizeEvents);

Open in new window