Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to set img to blank

Status
Not open for further replies.

dudleys

Technical User
Apr 28, 2005
31
AU
Hi,

Can anyone tell me how to set an img to blank ie so you can see the alt property when viewing the page.

I have tried

img1.src = null

Thanks in advance
 
dudleys,

Do it like this?
[tt]
<html>
<head>
</head>
<body>
<img src="myimg.jpg" alt="file myimg.jpg" /><br />
<button onclick="document.images[0].src=null">hide image</button></br />
<button onclick="document.images[0].src='myimg.jpg'">unhide image</button><br />
</body>
</html>
[/tt]
regards - tsuji
 

dudleys,

If you also give the image a title attribute, you will be able to see the text while the mouse is over the image (broken or otherwise, I believe).

Relying on the alt text to show in its entirety may not always be practical if the image dimensions are quite small.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top