This might be quiet simple though, but I am just some few months old in web development and i got dead stuck here. I have a page with multiple image items set to one class. By this, I meant the following code
<img src="http://img1.gif" id="GA2" class="CHAngeR" />
<img src="http://img1.gif" id="GA2" class="CHAngeR" />
and i want to execute a function that edits/appends the "src" attribute of the images at ones.
I tried using the same Id, but i discovered that w3c speculations are contrary, i also tried the following code but still doesn't work, how can i do this.
<!DOCTYPE html>
<html>
<head>
<title>DOWNLOAD PAGE</title>
<input type="button" value="change image" id="iMgChAnGe" onclick="changeIMG()"/>
<div class="changer">
<img src="http://img1.gif" id="GA1" class="CHAngeR" />
<img src="http://img2.gif" id="GA2" class="CHAngeR" />
<img src="http://img3.gif" id="GA3" class="CHAngeR" />
<img src="http://img4.gif" id="GA4" class="CHAngeR" />
<img src="http://imgl.gif" id="GA5" class="CHAngeR" />
</div>
<script>
function ChangeIMG(){
document.getElementByClassName(CHAngeR).setAttribute("src","http://google.com/img/images/static.gif");
}
</script>
</head>
</html>