javascript - Any way to bind event handler and call it at the same time? -


i have code following:

var f = function() {...};  $(window).resize(f);  f(); 

as can see, i'd f called every time window resized, , f called once after make resize event handler.

is there way can make code shorter/more succinct? ideally i'd eliminate need f variable , make anonymous function (i.e. $(window).resize(function() {...}), need way of calling function once...

$(window). resize(function () {console.log("stop resizing me!");}). resize(); 

http://jsfiddle.net/kmhzf/1/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -