javascript - Change image on click -


i have table , change image in <td> when click must url of image determine before.

that url of image type link of page(for example click on img)

index.html?type=dog 

then script read variables link. create variable script.

type = httpgetvars["type"] 

now when click on img of cat, script should replace cat.png dog.png , tried in way.

<img src="cat.png" onclick="document.write("<img src=\""+ type + ".png\">); 

<img id="foo" src="cat.png /> 

give <img> id - foo example than:

document.getelementbyid('foo').src = type +".png"; 

you change existing <img> src new image.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -