jQuery $ .proxy () method
Examples
Enforcement context "test" function objPerson within:
$("button").click($.proxy(objPerson,"test"));
try it"
Definition and Usage
$ .proxy Method takes an existing function, and returns the new function with a particular context.
This method is often used to point to elements in the context of different objects to add an event.
Tip: If you bind a function from $ .proxy returned, jQuery can still pass the original function unbind the correct function.
Syntax 1
$(selector).proxy(function,context)
尝试一下
Syntax 2
$(selector).proxy(context,name)
尝试一下
参数 | 描述 |
---|---|
function | 要被调用的已有的函数。 |
context | 函数所在的对象的名称。 |
name | 已有的函数,其上下文将被改变(应该是 context 对象的属性)。 |