$(this) dom对象错误的问题

setTimeout(get_redis_num,5000);

function  get_redis_num(){

$(‘.span_redis‘).each(function(){

var message = $(this).attr(‘id‘);

var that = this;

$.get(‘ajax.php?redis_id=‘+message,{},function(data){

if(data.nums){

var  nums = data.nums;

if(nums > 0){

messages= "剩余"+nums+"个车位";

}else{

messages ="车位不足";

}

}

$(that).html(messages);

},‘json‘);

});

setTimeout(get_redis_num,5000);

}

时间: 2024-10-28 23:39:50