jQuery proxy: Main Tips
- The jQuery
.proxy()method takes an existing function and returns a new one with a specific context.
- Since jQuery 1.6,
.proxy()accepts unlimited number of additional arguments. They will be passed to the function whose context is set to change.
Using the .proxy() Method
There are two methods for changing the value of
this: .call() and .apply().
.proxy() serves the same purpose: it changes the value of
this for a specific function and returns that new function.
The example below sets the context of the
info function inside
Syntax for jQuery .proxy()
The syntax of jQuery
.proxy() is as follows:
Let's review the arguments jQuery
nameis the name of the function whose context will be changed.
contextrepresents the object to which the context of the selected function will be changed.
- You can also add
extraArgumentsat the end.
Note: changing the order of parameters makes no difference – the .proxy() jQuery method would still work.
Latest Coupon Found:
TOP-RATED CODING COURSES
Learn the skills of tomorrow
The best time to learn programming is now - follow this link to access 100+ coding courses and enjoy learning at a very low cost!