<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <title>JQ minimum code to achieve title title switching content</title> <link rel="stylesheet" href="base.css" /> <script type="text/javascript" src="jquery-1.10.1.min.js" ></script> </head> <body> <script> $(function() { skipTitle (); }); function skipTitle () { var index = 0; var arr = ['☆☆★First title★☆☆', '☆★☆Second title☆★☆', '★☆☆Third title☆☆★']; //Initialize the title, you can delete the article $(document).attr('title',arr[0]); setInterval(function(){ //document.title = arr[index%arr.length]; index++; $(document).attr('title',arr[index%arr.length]); }, 3000); } </script> </body> </html>
If it is two content switching, this will be shorter
function skipTitle () { var index = 0; setInterval(function(){ index%2==0?document.title='☆★First title★☆':document.title='★☆Second title☆★'; index++; }, 3000); }
Effect picture: