I have removed a few pieces of code to pinpoint where it is and what is behind it in the div
"wrapper
". There are more div
's designed to display other stuff, but they don't have the class name of "changeimage
".
<div id="wrapper">
<div id="content">
<div align="center" id="imagesbar">
<img class="changeimage" src="image1.jpg"/>
</div>
<div align="center" id="imagestext">
<h1 class="headertext"><strong>What we do.</strong></h1>
<br /><p class="circle" >Mowing</p>
<p class="circle">Lawn Care</p>
<p class="circle">Weed Removing</p>
</div>
</div>
</div>
And the JavaScript:
var images = ['image1.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg', 'image5.jpg', 'image6.jpg', 'image7.jpg'];
var interval = setInterval(changeImage, 4000);
var index = 0;
function changeImage(){
//alert("changing image")
document.getElementsByClassName("changeimage").src = images[index];
index++;
}
In the line "document.getElementsByClassName("changeimage")
" is the one with the code that has the error. It seems that the browser I'm using (which is Chrome) cannot find the class name "changeimage
". I would like to change the src
tag on the HTML entry img
with the class name of "changeimage
" to be different locations in the string array in the JavaScript depending on the index.