$('.element').each(function(){
$(this).load('file.php',function(){
$(this).show(); // this row is not working
});
});
or
$('.开发者_JS百科element').each(function(){
setTimeout(function(){
$(this).show(); // this row is not working
},1000);
});
$('.element').each(function(){
var $this = $(this);
$this.load('file.php',function(){
$this.show();
});
});
or:
$('.element').each(function() {
var $this = $(this);
window.setTimeout(function() {
$this.show();
},1000);
});
you need to save it in a variable or pass into inner function
$('.element').each(function(){
var outerObj = this;
$(this).load('file.php',function(){
$(outerObj).show(); // this row is not working
});
});
You can try use jQuery.proxy() transfer object inside to other scope.
精彩评论