Hey wasn’t sure how to explain or ask this question so I’ll demonstrate with code, say I have this:
$(function() {
$(window).resize(foo());
function foo() {
alert('bar');
}
});
How do I make that work instead of doing this:
$(window).resize(function() {
foo();
});
You basically need to pass the function pointer to jquery.. when you do
function(){foo();}you are creating an anonymous function.Live Demo