更新时间:2022-02-26 06:52:56
提供一系列提示.然后将5秒钟的interval
更改div的内容.我假设您想要随机提示.
Make an array of tips. Then make a interval
of 5 seconds that change the div's content. I assume you want random tips.
See this example on jsFiddle.
var tips = [
"Tip 01",
"Tip 02",
"Tip 03",
"Tip 04",
"Tip 05",
"Tip 06",
"Tip 07",
"Tip 08",
"Tip 09"
];
// get a random index, get the value from array and
// change the div content
setInterval(function() {
var i = Math.round((Math.random()) * tips.length);
if (i == tips.length) --i;
$("#tip").html(tips[i]);
}, 5 * 1000);
请参阅: