Jump to content

document.getElementById("").src


jmurph333

Recommended Posts

When I was first starting JavaScript I read "Head First JavaScript" (Great Book!) and it used a specific method so that when a button or image is clicked, it can adjust the source of the image.

<head><script type="text/javascript">function changeImage() {document.getElementById("iRock").src = "iRock_Happy.png";}</script></head><body><img src="iRock.png" id= "iRock" onclick="changeImage()"></body>

I used almost the exact same code as this except with my pictures, although it does not work.Any thoughts?

Link to comment
Share on other sites

The only other problem I can see is that the image might be a little slow loading. click on it and wait a few seconds to see if it changes.Make sure the image exists and that the file path is correct too.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...