以下是函数的代码:
$Core.notification =
{
bDebug: false,
update: function()
{
setTimeout('$.ajaxCall("notification.update", "", "GET");', 1000);
},
setTitle: function()
{
var iTotal = 0;
var sTitle = $('title').html();
$('.holder_notify_count').each(function(){ alert($(this));
iTotal += parseInt($(this).html());
});
var newTitle = '';
var aMatches = sTitle.match(/(\([0-9]*\))/i);
if (aMatches !== null && isset(aMatches[1])){
if (iTotal > 0){
newTitle = '(' + iTotal + ') ' + sTitle.replace(aMatches[1], '');
//$('title').html(newTitle.replace('#',''));
// document.title = newTitle.replace('#', '');
}
else{
//$('title').html(aMatches[1].replace('#',''));
// document.title = aMatches[1].replace('#', '');
}
}
else{
if (iTotal > 0){
//$('title').prepend('(' + iTotal + ') '); // it doesnt work in IE8
// ie8 doesnt like hashes
var NewTitle = document.title.replace('#','');
// document.title = '(' + iTotal + ') ' + NewTitle;
}
else{
}
}
if (getParam('notification.notify_ajax_refresh') > 0)
{
setTimeout('$.ajaxCall("notification.update", "", "GET");', (this.bDebug ? 10000 : (getParam('notification.notify_ajax_refresh') * 60000)));
}
}
};
仅考虑上述代码中的以下两行,而忽略其余代码:
$('.holder_notify_count').each(function(){
iTotal += parseInt($(this).html());
});
我不明白其中$(this)
包含什么?我alert($(this));
在里面试过$('.holder_notify_count').each(function(){.....});
但是它只能打印出来,[object Object]
所以我无法找出其中$(this)
包含的内容以及应该如何打印?
谢谢。
$(this)是对象($('。holder_notify_count'))$(this).html()表示$('。holder_notify_count')内部的html
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句