I have some code like the following:
var f = function() {...};
$(window).resize(f);
f();
As you can see, I'd like f
to be called every time the window is resized, and also for f
to be called once after I make it the resize event handler.
Is there any way I can make this code shorter/more succinct? Ideally I'd like to eliminate the need for an f
variable and just make it an anonymous function (i.e. $(window).resize(function() {...}
), but I need some way of calling the function once...