$.proxy

强制执行 objPerson 内的 "test" 函数的上下文:

$("button").click($.proxy(objPerson,"test"));

语法 1

$(selector).proxy(function,context)

语法 2

$(selector).proxy(context,name)
function:要被带调用的函数
context:要被调用的函数所在的对象名称
name:属性
例如:
语法二例子:
$(document).ready(function(){
  var objPerson = {
    name: "John Doe",
    age: 32,
    test: function(){
      $("p").after("Name: " + this.name + "<br> Age: " + this.age);
    }
  };
  $("button").click($.proxy(objPerson,"test"));
});
原文地址:https://www.cnblogs.com/webcyh/p/11278223.html