Controlling the value of ‘this’ in a jQuery event

You can use jQuery.proxy() with anonymous function, just a little awkward that ‘context’ is the second parameter.

 $("#button").click($.proxy(function () {
     //use original 'this'
 },this));

Leave a Comment