【发布时间】:2010-11-04 18:26:18
【问题描述】:
我的网站上有一个聊天功能,我想复制 Facebook 的功能,即当有新消息进入时,在标题标签中闪烁“来自 John 的新消息”。但是,我可以为新消息的一个实例执行此操作我需要为所有新消息执行此操作(无限可能)。因此,需要创建一个 setInterval 循环,并在发送新消息的人的姓名之间循环。假设 John、Sue、George 和 Katy 给我发了新信息;这是我目前所拥有的:
$("div .labels").each(function(){ //.labels where each persons name is displayed in the bottom banner bar
var senderFirstName = $(this).attr('rel');
//this is where I need to create the array "AllNames" containing all of the sender names
});
现在我有了包含所有向我发送消息的人的名字的数组“AllNames”,我需要每 1500 毫秒循环一次该数组并更改标题标签以反映新名称。
var BlinkTitle = setInterval(function(){
$("title").text("message from " + AllNames[0]); //AllNames array needs to cycle through the array values every time the interval loops.
},1500);
请帮忙!!
【问题讨论】:
标签: jquery arrays tags title setinterval