<div id="changeText" ></div>
<script type="text/javascript">
var text = ["Welcome", "Hi", "Sup dude"];
var counter = 0;
var elem = document.getElementById("changeText");
setInterval(change, 1000);
function change() {
elem.innerHTML = text[counter];
counter++;
if(counter >= text.length) { counter = 0; }
}
</script>
如何为这个 javascript 代码添加淡入淡出效果?另外,我如何让它以“欢迎”而不是空白开头?我会非常感谢你的帮助。