JS中怎样用for循环做个文字倒计时出现的小程序、 就是隔几秒出现一个文字、
这是我写的代码、有问题的,帮忙修改下、谢谢!<title>无标题文档</title><scripttype="text/javascript">vararrs=["隔",...
这是我写的代码、有问题的 ,帮忙修改下、谢谢!
<title>无标题文档</title>
<script type="text/javascript">
var arrs=["隔","几","秒","出","现","一","个","文","字","、"]
var i=0;
function operA(){
var divObj=document.getElementById("divA");
for(i;i<arrs.length;i++){
divObj.innerHTML+=arrs[i];
//alert(arrs[i]);
continue;
}
setTimeout("operA()",5000);
}
</script>
</head>
<body>
<div id="divA"></div>
<form>
<input type="button" value="按钮" name="" onclick="operA()" />
</form>
</body> 展开
<title>无标题文档</title>
<script type="text/javascript">
var arrs=["隔","几","秒","出","现","一","个","文","字","、"]
var i=0;
function operA(){
var divObj=document.getElementById("divA");
for(i;i<arrs.length;i++){
divObj.innerHTML+=arrs[i];
//alert(arrs[i]);
continue;
}
setTimeout("operA()",5000);
}
</script>
</head>
<body>
<div id="divA"></div>
<form>
<input type="button" value="按钮" name="" onclick="operA()" />
</form>
</body> 展开
2个回答
展开全部
你应该使用 setInterval,而不是 setTimeout,for 用不上
<script type="text/javascript">
var arrs=["隔","几","秒","出","现","一","个","文","字","、"];
var i=0;
function operA() {
setInterval(function() {
if(i == arrs.length) {
i = 0;
}
document.getElementById("divA").innerHTML += arrs[i];
i++;
}, 50);
}
</script>
博思aippt
2024-07-20 广告
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT...
点击进入详情页
本回答由博思aippt提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询