Javatpoint Logo
Javatpoint Logo

jQuery $.proxy() method

The $.proxy() method takes an existing function and returns a new one that has a specific context. It is generally used to attach events to an element where the context points back to a different object.

Syntax

We can use the below syntaxes for using the $.proxy() method.

The $.proxy() method accepts some parameters that are defined as follows -

function: It specifies the existing function to be called.

context: It is the object name where function lies.

name: It is the function name whose context is to be changed. It should be a property of the context object.

Now, let's see some of the illustrations of using the $.proxy() method.

Example1

In this example, we are using the function and context parameters of the $.proxy() method. Here, the context of the span element will be displayed.

Test it Now

Output

After the successful execution, the output will be -

jQuery $.proxy() method

After clicking the text Click me, the output will be -

jQuery $.proxy() method

Example2

In this example we are using the context, and name parameters of the $.proxy() method.

Test it Now

Output

jQuery $.proxy() method

After clicking the given button, the output will be -

jQuery $.proxy() method





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA