Closed Thread Icon

Preserved Topic: Read ALT Tag (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18418" title="Pages that link to Preserved Topic: Read ALT Tag (Page 1 of 1)" rel="nofollow" >Preserved Topic: Read ALT Tag <span class="small">(Page 1 of 1)</span>\

 
Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 08-25-2002 10:07

Hello,

Say, is it possible to read the ALT Tag using JavaScript? If so... I'm looking to write a JavaScript/DHTML function that will read the ALT tag for specified graphic that a client floats over -- then update the text inside a DIV tag.
Has anyone done this before?

Karl

Karl www.AZProGolf.com
karl@azprogolf.com

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 08-25-2002 11:06

This topic belongs in DHTML/JavaScript board. Even you have mentioned JavaScript in your post, so I'll move it to the appropriate location...

Anyway, to answer your question...

If your image has ID defined, you can use the following code:

alert(document.getElementById("imgID").getAttribute("alt"));

Otherwise you can use the following code:

alert(document.getElementsByTagName("IMG")[0].getAttribute("alt"));

The number between square brackets represents zero based index of image whose ALT parameter value you want to read...


« BackwardsOnwards »

Show Forum Drop Down Menu