我正在创建一个网站,每次都需要显示不同的消息。我在HTML中使用了<blink>
个标记。
使用<blink>
,我们只能使一个文字闪烁。
答案 0 :(得分:1)
var messages = ["OK, I admit...", "...that I only answered this...", "...because I was curious to see...", "...if it could be done in one line...", "...which apparently it can...", "...though it is silly to do so..."];
setInterval(((i =-1, m = document.getElementById("message")) => () => m.innerHTML = m.innerHTML==="" ? messages[i=(i+1)%messages.length] : "")(), 1000);
<p id="message"></p>