JQuery implements the method of prompting a new message with a flickering title.
This example describes how jQuery implements the prompt of the flickering title of a new message. Share it with you for your reference. The details are as follows:
This code can display the prompt information in the title bar.
1. jQuery plug-in style code
; (Function ($) {$. extend ({/*** call method: var timerArr = $. blinkTitle. show (); * $. blinkTitle. clear (timerArr); */blinkTitle: {show: function () {// when there is a new message, the following message is displayed: 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 = '[new message]' + _ title };}, 500); return [timer, _ title] ;},/*** @ param timerArr [0], timer mark * @ param timerArr [1], initial title text content */clear: function (timerArr) {// remove the flickering prompt and restore the initial title text if (timerArr) {clearInterval (timerArr [0]); document. title = timerArr [1] ;}}}) ;}) (jQuery );
2. The call method is as follows:
JQuery (function ($) {var timerArr = $. blinkTitle. show (); setTimeout (function () {// automatically disappears after a certain period of time $. blinkTitle. clear (timerArr) ;}, 10000); // if the human operation disappears, you only need to call this method: $. blinkTitle. clear (timerArr );});
Click here to download the complete instance code.
I hope this article will help you with jQuery programming.