js怎样可以访问外围对象的this方法 button.onclick = $.proxy(function() {//这里可以直接用this访问外围对象}, this); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if(Function.prototype.bind){ Function.prototype.bind = function(context){ if(arguments.length<2&&context==void 0){ return this; } var _method=this,args=[].slice.call(arguments,1); return function(){ return _method.apply(context,args.concat.apply(args,arguments)); } }}button.onclick = function(){ //this === "外围变量";}.bind("外围变量"); if(!Function.prototype.bind){ Function.prototype.bind = function(context){ if(arguments.length<2&&context==void 0){ return this; } var _method=this,args=[].slice.call(arguments,1); return function(){ return _method.apply(context,args.concat.apply(args,arguments)); } }}button.onclick = function(){ //this === "外围变量";}.bind("外围变量"); 答的好。这样不行吗?button.onclick = function() {//这里想要调用外围对象的某个方法 //此时this指代的是button对象,而不是外围对象。这里不能使用this.方法名} (function (me) { me.方法//这个指的就是外面的this吧? })(this); javascript验证空白输入框 不起作用! 一段JS验证代码,可有高人来简化下 DIV 层覆盖问题? |zyciis| 如何用jquery判断一个对像是否已经包含了某个CSS,谢谢 FCKeditor编辑器这么只有ASP,PHP.....没有JSP版呀?。。。 用正则表达式,如果替换标签外的空格?谢谢 [求代码]可以自动算出两个时间的差,并显示的JAVASCRIPT代码 meizz(梅花雪) ,刚才结贴好像分没给你加上,到这里来取分 location的用途 怎么得出层的宽度和高度? jquery跨域加载页面的问题 JS中怎么判断用户是否在输入文字
if(Function.prototype.bind){
Function.prototype.bind = function(context){
if(arguments.length<2&&context==void 0){
return this;
}
var _method=this,args=[].slice.call(arguments,1);
return function(){
return _method.apply(context,args.concat.apply(args,arguments));
}
}
}
button.onclick = function(){
//this === "外围变量";
}.bind("外围变量");
if(!Function.prototype.bind){
Function.prototype.bind = function(context){
if(arguments.length<2&&context==void 0){
return this;
}
var _method=this,args=[].slice.call(arguments,1);
return function(){
return _method.apply(context,args.concat.apply(args,arguments));
}
}
}
button.onclick = function(){
//this === "外围变量";
}.bind("外围变量");
这样不行吗?
button.onclick = function() {
//这里想要调用外围对象的某个方法
//此时this指代的是button对象,而不是外围对象。这里不能使用this.方法名
}
(function (me) {
me.方法//这个指的就是外面的this吧?
})(this);