每个闪烁以显示不同的消息

时间:2016-08-31 01:26:48

标签: javascript html

我正在创建一个网站,每次都需要显示不同的消息。我在HTML中使用了<blink>个标记。

使用<blink>,我们只能使一个文字闪烁。

1 个答案:

答案 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>