我想实现这样的事情:传递这个对象在回调函数jQuery选择
function theMain (sel,call) {
var el = $(sel) ;
// Some processes etc...
call("done") ;
}
theMain("div a",function(state){
if (state == "done") {
// Want "THIS" to be an DOM object,
// But it refers WINDOW object...
$(this).css("border","1px solid red") ;
}
}) ;
jQuery让,不知怎的,但如何?
还是我必须做这样的:
function theMain (sel,call) {
var el = $(sel) ;
// Some processes etc...
call(el,"done") ;
}
theMain("div a",function(that,state){
if (state == "done") {
that.css("border","1px solid red") ;
}
}) ;
任何建议?
这没有很大的意义。你试图达到什么目标? –
我希望“THIS”是第一个代码中的一个DOM对象,但它指WINDOW对象@LeeTaylor – Digerkam