views:

26

answers:

1

Can anyone tell me how I can access the following line of HTML in JavaScript, please? I cannot seem to find the image object in JavaScript:

<td colspan="2" rowspan="5"><img src="../image/6765.jpg" width="330" height="130" />

The end result is that I want to change the images. Thanks for any help !

+1  A: 

You should give your <img> element a unique id:

<img id="myImage" src="../image/6765.jpg" width="330" height="130" />

Then in JavaScript you should be able to get a reference to your element with document.getElementById():

document.getElementById('myImage').src = 'new-image.jpg';
Daniel Vassallo