I want to "animate" the page title in the browser tab to alternate between two states every second like this example:
- Page Title
- ⭐ Page title
How can I do this?
Thanks!
CodePudding user response:
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)