我有一个文本框,其内容会在页面重新加载时发生变化,但我想知道如何使其在指定的时间后发生变化。没有闪光灯这可能吗?
最佳答案
将此代码复制并粘贴到 html 文件中并查看,您应该很容易编辑以满足您自己的需要。享受吧:o)
<html>
<head>
<script type="text/javascript">
//Change these messages to what ever you would like to display in the textbox
//You can add or remove any as you see necessary
var messages = new Array(
"Hello",
"there",
"my",
"name",
"is",
"Chief17!"
);
var i = 0;
function changeText()
{
document.getElementById("tb").value = messages[i];
if(i < messages.length -1)
{
i++;
}
else
{
i = 0;
}
}
</script>
</head>
<!--Change the 1000 to how long you want to wait in between message changes (1000 is 1 second)-->
<body onLoad="setInterval('changeText()',1000)">
<input type="text" id="tb" />
</body>
</html>
关于javascript - 文本框中的文本更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3071175/