$.proxy的使用
来源:互联网 发布:sqlserver 字段默认值 编辑:程序博客网 时间:2024/06/06 03:16
1、$.proxy 方法接受一个已有的函数,并返回一个带特定上下文的新的函数。
有两种语法:语法1:$(selector).proxy(function,context)
语法2:$(selector).proxy(context,name)
参数:
function要被调用的已有的函数。context函数所在的对象的名称。name已有的函数,其上下文将被改变(应该是 context 对象的属性)。例:
1、$(document).ready(function(){
test=function()
{
this.txt="这是一个对象属性";
$("div").click($.proxy(this.myClick,this));
};
test.prototype.myClick = function(event)
{
alert(this.txt);
alert(event.currentTarget.nodeName);
};
var x = new test();
});
<div>这是一个 div 元素。</div>
2、$(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"));
});
<button>执行 test 函数</button>
<p></p>
阅读全文
0 0
- 代理服务器 (proxy) 的使用
- ICE的proxy使用
- jquery $.proxy的使用
- nginx proxy的使用
- $.proxy的使用
- 动态类Proxy的使用
- 2013-Proxy代理的使用
- atlas mysql-proxy 的使用
- 使用Java的Proxy类实现动态代理(Dynamic Proxy)
- Ubuntu终端使用的proxy的设置
- 如何使用SIPp测试ReSIProcate的Proxy
- [Android]正确地访问网络资源----Proxy的使用
- [Android]正确地访问网络资源----Proxy的使用
- 使用Java的Proxy保护代理
- 使用nginx作为websocket的proxy server
- jQuery中$.proxy()的原理和使用
- Proxy SwitchyOmega代理插件的使用
- jQuery中$.proxy()的原理和使用
- jquery 函数应用小功能实现
- Yoshua Bengio建议的机器学习路线图
- Android AsimpleCache 缓存ArrayList数据
- 2017.1版的idea安装破解
- git Branch切换
- $.proxy的使用
- 自定义异常
- git的webhook应用
- Eclipse中 sysout 按alt+/为什么不出System.out.println();
- Linux 如何改变输出的内容
- AndroidStudio中debug快捷键
- Android基础总结五:ImageSwitcher的使用
- nyojzb的生日
- Jenkins入门系列之——01第一章 Jenkins是什么?