【发布时间】:2021-11-02 21:54:21
【问题描述】:
我有这个代码:
$(function(){
$("#CASA").click(function(){
rsExecute("rs/rs_luci.php","premi",1,function(cc){});
var col=$( this ).css( "background-color" );
setColor(this, 'yellow');
setTimeout(setColor,1000,this,col);
});
});
function setColor(obj,clr){
$(obj).css( "background-color", clr );
}
rsExecute 通过 ajax 进行调用。 function(cc){} 成功执行。
我尝试过像这样更改代码:
$(function(){
$("#CASA").click(function(){
rsExecute("rs/rs_luci.php","premi",1,function(cc){
var col=$( this ).css( "background-color" );
setColor(this, 'yellow');
setTimeout(setColor,1000,this,col);
});
});
});
function setColor(obj,clr){
$(obj).css( "background-color", clr );
}
但它不起作用,因为 this 未定义。
有没有办法将 this 对象传递给 rsExecute 内部的函数?
【问题讨论】:
标签: javascript jquery ajax