By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,131 Members | 1,425 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,131 IT Pros & Developers. It's quick & easy.

document.getElementById issue inside a div

P: 3
hi,
im using this javascript..

document.getElementById(link).src="test.png"

and this html

<img id="link" src="">

it works fine and sets the html src to test.png - but as soon as i put the <img> tag inside a div - it wont display

e.g.

<div id="doesntworknow">
<img id="link" src="">
</div>

Any ideas ? thanks!
Jan 18 '08 #1
Share this Question
Share on Google+
4 Replies


P: 55
Hi there !

i guess u missed the quotes for the object id being referenced...

Expand|Select|Wrap|Line Numbers
  1. document.getElementById(link).src="test.png"
cheers !
Jan 19 '08 #2

P: 55
Hi there !

i guess u missed the quotes (use either single or double quote)
for the object id being referenced...

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("link").src="test.png"
cheers !
Jan 19 '08 #3

P: 3
i tried that a couple of times, doesnt seem to make a difference?

thanks!
Jan 20 '08 #4

P: 3
ok ignore this post now, i just looked at my css code and noticed that all divs were set to display none, how silly do i feel!
Jan 20 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.