I'm a noobie to javascript in general. The question that I can't seem to wrap my head around is how I can't make these buttons interact with a particular image. Here is my code:
I want to make it so that the "Change Image" button changes the .src variable of myImage. For some reason, it won't change the data for the image. Can anyone help?Code:<html> <head> <title>Moving Images</title> </head> <body> <img src="me.png" name="changePic" alt="That's me!"> <script language="javascript" type="text/javascript"> var changingImage = new Image(); changingImage.src = "me.png"; function changeImage() { changingImage.setAttribute("src", "me2.png"); } </script> <input type="button" value="Change Image" onClick="changeImage()" class="run_button"> </body> </html>


Reply With Quote

Bookmarks