嗨,目前我有一些 Javascript 可以让我的图像自动循环遍历存储在数组中的多个图像,但是我怎样才能对 H2 文本对象上的文本做同样的事情呢?
<SCRIPT LANGUAGE = "Javascript">
var p1 = new Image();
var p2 = new Image();
var p3 = new Image();
var p4 = new Image();
p1.src="images/223.png";
p2.src="images/335.png";
p3.src="images/225.png";
p4.src="images/226.png";
var imgArray = new Array (p1, p2, p3, p4);
var counter = 0;
var loop = 1;
setTimeout(scroll_forwards, 2000);
var end = imgArray.length - 1;
function scroll_forwards() {
if (counter == end){
counter = 0;
}
else {
counter++;
}
document.pic1.src = imgArray[counter].src;
setTimeout(scroll_forwards, 2000);
}
</SCRIPT>