Avatar of supportoranges
supportoranges
Flag for United States of America asked on

How can I reference this element using document in Javascript

I need to dynamically change the src attribute (see snippet below).  Please tell me how can I reference this using document in Javascript.  I have limited Javascript exp.

<td width="150" height="198"><img border=0 width=150 height=76 src=http://ep.yimg.com/ca/I/yhst-123908713209812348></td>
JavaScript

Avatar of undefined
Last Comment
supportoranges

8/22/2022 - Mon
Kim Walker

Can you modify the html? If the img tag had an id attribute, you could reference it by its id. For example:

<img id=myimage" border="0" width="150" height="76" src="http://ep.yimg.com/ca/I/yhst-123908713209812348">

Open in new window

could be referenced in javascript by:

document.getElementById("myimage").src = "http://newurl";

Open in new window

supportoranges

ASKER
I cannot add id attribute on the img tag but i can add it on the <td>

THIS IS POSSIBLE:
 <td id="cellContainingImage" width="150" height="198"><img border=0 width=150 height=76 src=http://ep.yimg.com/ca/I/yhst-1234567890></td>

The reason I can't add id attribute on img tag is because html for <img> tag is generated using Yahoo store tag.
ASKER CERTIFIED SOLUTION
Kim Walker

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
supportoranges

ASKER
That will work - lovely!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
supportoranges

ASKER
Thank you, that was very helpful