Code:
<html>
<head>
<title>Change on Click</title>
<script type="text/JavaScript">
function cngImage(im1,im2,id){
a=document.images[id].src.slice(document.images[id].src.length-im1.length);
if (a==im1)
document.images[id].src=im2;
else
document.images[id].src=im1;
}
</script>
</head>
<body>
<img id=p1 src=dl.gif onClick=cngImage('dl.gif','fl.gif',this.id)>
<img id=p2 src=bl.gif onClick=cngImage('bl.gif','cl.gif',this.id)>
</body>
</html>
All you need to know is:
1) The script needs no configuration.
2) Each image tag on the page must have a unique id.
3) The only other thing to configure are the two images in the onClick event, the first is the starting image the second is the alternate image, leave this.id as the third parameter in all cases.
Bookmarks