Forum Moderators: open
I'm sure this question must have been asked several times already but I can't get the site search facility to work so I can't check.
I want to add some (simple) javascript to my site so I can click on a thumbnail image to change the main image on the page. I need it to be standards compliant XHTML so I don't want to use the deprecated 'name' attribute for <img>. Is that possible?
Thanks!
<script type="text/javascript">
var imgs = new Array("images/pic0.jpg","images/pic1.jpg");
function loadMainImg(num) {
document.getElementById("mainImg").src = imgs[num];
}
</script>
<img id="thumb0" onclick="loadMainImg(0)" src="thumbs/pic0.jpg"/>
<img id="thumb1" onclick="loadMainImg(1)" src="thumbs/pic1.jpg"/>
<img id="mainImg" src="images/somePic.jpg"/>