jQuery.proxy(function, context) returns a new function that always runs with this set to context (since 1.4). Extra arguments for partial application arrived in 1.6.
Remember
var me = { type: "zombie", test: function () { return this.type; } };
// Without proxy — this is the button
$("#btn").on("click", me.test);
// With proxy — this is me
$("#btn").on("click", $.proxy(me.test, me));
// Modern replacement
$("#btn").on("click", me.test.bind(me));
Wrap a method before passing it to .on() so this stays your object.
Identify the method that needs a fixed this.
Call $.proxy(fn, context) or $.proxy(context, "methodName").
Pass the returned function to .on() / .one().
Optional: add extra args after context for partial application (1.6+).
Unbind with a namespace when the same function is proxied in multiple ways.
Signature
Since
Role
$.proxy(fn, context)
1.4
Bind a function to a context
$.proxy(context, name)
1.4
Bind context[name] to context
$.proxy(fn, context, …args)
1.6
Also prepend extra arguments
$.proxy(context, name, …args)
1.6
Name form + partial application
Pseudocode
Pseudocode
proxy = $.proxy(FN, CONTEXT [, EXTRA…])
when proxy is called with CALL_ARGS:
set this = CONTEXT
(if CONTEXT was null/undefined since 1.9: keep caller's this)
invoke FN(EXTRA…, CALL_ARGS…)
attach:
$("#el").on("click", proxy)
modern:
$("#el").on("click", FN.bind(CONTEXT [, EXTRA…]))
Reference
Cheat Sheet
Keep these facts handy while fixing this bugs.
Topic
Detail
Returns
Function (bound wrapper)
Since
1.4 · extra args 1.6 · null context 1.9
Deprecated
3.3 → use Function.prototype.bind
Without proxy
this in a handler = the DOM element
With proxy
this = your context object
Unbind tip
Prefer event namespaces over matching proxy refs
Element still available
Use event.target / event.currentTarget
Try it
Live Preview
Compare a raw method vs $.proxy() vs .bind() on the same button.
Run an action to rebind, then click the test button.
Result
Ready — pick a bind style and click Test.
Code
jQuery Examples
Short, copy-ready snippets. Prefer Function.prototype.bind in new projects.
Example 1 — Function + Context
Lock this to your object when the handler runs.
jQuery
var me = {
type: "zombie",
test: function (event) {
$("#out").text("Hello " + this.type);
// element is still available:
// event.target
}
};
$("#test").on("click", $.proxy(me.test, me));
Extras.you and they are bound as the first two args.
Context.this is still me ("dog").
Event. jQuery appends the event object after the extras.
Order. Handler signature is (one, two, event).
Example 4 — With vs Without Proxy
Same method, two binds — see how this differs.
jQuery
var you = {
type: "person",
test: function () {
$("#out").append(String(this.type) + " ");
}
};
$("#raw").on("click", you.test); // this → button
$("#proxied").on("click", $.proxy(you.test, you)); // this → you
Bind. Native ES5 does the same job without jQuery.
Prefer. Use .bind() in new code; keep $.proxy only in legacy paths.
Edge Cases & Pitfalls
Watch for these when locking this for handlers.
unbind
Shared proxy identity
Proxies of the same function can share jQuery’s handler id — use unique event namespaces when unbinding.
element
this is no longer the element
After proxying, read the DOM node from event.target or event.currentTarget.
args
Extra args come first
Bound extras prepend; the event is not always the first parameter anymore.
deprecated
Prefer .bind() for new code
Since jQuery 3.3, native bind is the recommended replacement.
Compatibility
Browser Support
jQuery.proxy() has been available since jQuery 1.4 and is deprecated since 3.3 (still present). Prefer Function.prototype.bind in modern browsers.
✓ Deprecated · jQuery 1.4+
jQuery.proxy()
Works wherever your loaded jQuery version includes it. New code should use Function.prototype.bind instead.
LegacyUse .bind() instead
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
$.proxy()Deprecated
Bottom line: Fine for reading legacy jQuery apps. Migrate new handlers to fn.bind(context).
Analysis
Performance Notes
Approach
Cost
Best for
$.proxy() / .bind() once
Tiny
Create the wrapper when binding, reuse it
New proxy on every render
Wasteful
Cache the bound function if you rebind often
Arrow functions
Tiny
Lexical this without proxy/bind (modern JS)
Creating a bound function is cheap. Avoid rebuilding proxies inside tight loops or on every mousemove.
Remember
Key Takeaways
Role: return a function with a fixed this context.
Status: deprecated since 3.3 — prefer fn.bind(context).
Events: proxy object methods before passing them to .on().
Unbind: use namespaces when the same function is proxied in multiple ways.
One line:$.proxy() locks this for callbacks — learn it for legacy code, write new code with .bind().
Frequently Asked Questions
jQuery.proxy(function, context) returns a new function that always runs with this set to context, no matter where it is called. That fixes event handlers where this would otherwise be the DOM element.
Yes. As of jQuery 3.3, prefer native Function.prototype.bind(). $.proxy() still works in jQuery 3.x for legacy code, but new projects should use fn.bind(context).
Both lock this. $.proxy(fn, ctx) is jQuery’s version (since 1.4). It also accepts $.proxy(context, "methodName"). Native bind is the modern standard and needs no jQuery.
Passing obj.handle to .on("click", obj.handle) makes this the clicked element inside handle. $.proxy(obj.handle, obj) keeps this as obj so you can read properties and call other methods.
jQuery can often .off() using the original function, but proxied copies of the same function share tracking. Prefer unique namespaces: .on("click.myWidget", $.proxy(fn, ctx)) then .off("click.myWidget").
Yes, since 1.6: $.proxy(fn, ctx, arg1, arg2). Those args come first; later call-time args (like the event) follow. Since 1.9, a null/undefined context keeps the caller’s this for partial application only.