在一个回调函数中调用了Base.progress.init()的方法,如下所示:
function update_status(data, textStatus) {
if (textStatus=="success") {
for(i=0; i< data.length; i++) {
$("#on"+data[i].uuid).each(function() {
if (data[i].status=="ON") {
$(this).attr('status', "ONLINE");
} else if (data[i].status=="OFF") {
$(this).attr('status', "OFFLINE");
} else if (data[i].status == "ERRTKN") {
$(this).attr('status', "ERRTKN");
}else {
$(this).attr('status', "unknown");
}
Base.progress.init();
});
这里的这个Base.progress.init()方法是个javascript方法,如下所示:
Base.progress = {
init : function(){
var _this = this;
$('.progress').each(function(){
var status = $(this).attr('status');
if(status.length == 0){_this.unknown(this); return;};
_this[status](this);
});
$('.discinfo').each(function(){
var status = $(this).attr('status');
if(status.length == 0){_this.unknown(this); return;};
_this[status](this);
});
$('.progress_ha').each(function(){
var status = $(this).attr('status');
if(status.length == 0){_this.unknown(this); return;};
_this[status](this);
})
},
①请问在下面这个JavaScript方法中this和$(this)分别表示的什么呀?
②_thisstatus是什么意思?
③_this.unkown(this)是什么意思?
var _this = this
//这个this指的是调用这个方法的东西保存为 _this
//方便在函数里面调用$(this)就是获取$('.progress') $('.discinfo') $('.progress_ha')
// status 因为循环后这个就是个数组了,所以用_this[status]包裹代表调用的这个元素的status属性