2025年02月28日 建站教程
jquery做一个【title】闪动新消息提示效果,下面web建站小编给大家详细介绍一下实现代码!
实现代码如下:
(function($) {
$.extend({
blinkTitle : {
show : function() {
//有新消息时在title处闪烁提示
var step = 0, _title = document.title;
var timer = setInterval(function() {
step++;
if (step == 3) {
step = 1
}
if (step == 1) {
document.title = '【 】' + _title
}
if (step == 2) {
document.title = '【新消息】' + _title
}
}, 500);
return [ timer, _title ];
},
//去除闪烁提示
clear : function(timerArr) {
if (timerArr) {
clearInterval(timerArr[0]);
document.title = timerArr[1];
}
}
}
});
})(jQuery);
jQuery(function($){
var timerArr = $.blinkTitle.show();
setTimeout(function(){
$.blinkTitle.clear(timerArr);
}, 10000);
});
本文链接:http://so.lmcjl.com/news/24002/