This article mainly introduces jQuery's method of implementing the prompt of the new message blinking title. It analyzes jQuery operation styles and has some reference value, for more information, see the following example. 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.