I want to "animate" the page title in the browser tab to alternate between two states every second like this example:
How can I do this?
Thanks!
You could do something like:
const star = "⭐ ";
setInterval(() => {
if (!document.title.startsWith(star))
document.title = star + document.title;
else
document.title = document.title.replace(star, '');
}, 1000)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.