JavaScript使用setInterval更改图像和计数器

JavaScript使用setInterval更改图像和计数器,javascript,Javascript,因此,我正在使用JavaScript完成一个家庭作业。我遇到的问题是创建changeAd()函数,在5秒钟后将表中的起始图像替换为函数中的其他图像。我完全迷路了,所以非常感谢任何帮助或指点!这就是我到目前为止所做的: CVR1 /* = 0; 这需要努力 每次执行时,应将textfield的值更改为countdown,从15减少到0,当计数达到0时,清除两个间隔并将浏览器重定向到CVR2.html } /* ]]> */ 广告Central Vally Realtors主页将以文本字段秒显示

因此,我正在使用JavaScript完成一个家庭作业。我遇到的问题是创建changeAd()函数,在5秒钟后将表中的起始图像替换为函数中的其他图像。我完全迷路了,所以非常感谢任何帮助或指点!这就是我到目前为止所做的:


CVR1
/* = 0;
这需要努力
每次执行时,应将textfield的值更改为countdown,从15减少到0,当计数达到0时,清除两个间隔并将浏览器重定向到CVR2.html
}
/* ]]> */
广告

Central Vally Realtors主页将以文本字段秒显示。

setInterval中函数调用的第一件事是删除括号。 其次,我假设您知道如何声明一个数组来保存图像的名称,完成后您可以转到这里http://stackoverflow.com/questions/5915096/get-random-item-from-javascript-array 查看如何从此数组中获取随机元素。 最后,要更改javascript中的图像,请参见此处http://stackoverflow.com/questions/7312553/change-image-source-with-javascript. 我希望这有帮助。
这是我要使用的最后一个工作代码,我认为我没有正确使用startCountdown函数中指向的Textfield,但它可以工作


CVR1
/*(pix.length-1)){x=0}
}
var messages=新数组(
"15",
"14",
"13",
"12",
"11",
"10",
"9",
"8",
"7",
"6",
"5",
"4",
"3",
"2",
"1",
"0"
);
var计数=1;
函数startCountdown(){
document.getElementById(“计时器”).value=messages[count];
如果(计数 */
广告

中央山谷房地产经纪人主页将在几秒钟内显示。

First thing you should remove parentheses from the call to your functions in setInterval. Secondly I assume you know how to declare an array to save names of your images, after this is done you can go here http://stackoverflow.com/questions/5915096/get-random-item-from-javascript-array to see how to get a random element from this array. And finally to change the image in javascript you should refer here http://stackoverflow.com/questions/7312553/change-image-source-with-javascript. I hope this helped.