Hello all,
i am trying to do a script that let me change the src of an image when someone click on it. When the second image (a bigger image) appear and the user hit the image with a second click, appears the first image. And so on.
This is what i've done:
Code:
var newImage;
function swapImage(nomeid, newImage) {
if(document.getElementById('nomeid').src == newImage) {
document.getElementById('nomeid').src = "images/"+nomeid+"_big.jpg";
}else{
document.getElementById('nomeid').src = newImage;
}
}
and
Quote:
|
<IMG id="image1" SRC="images/image1.jpg" onClick="swapImage(image1,'images/image1.jpg')" />
|
But it dosn't work.
I need a generic script to be used easily in a page with a large number of images... and as u can see I don't know JS so much
Thanks for any hint...