English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Is there a way that I can set the image attributes alt and title to the same value without just repeating the attribute? In order to get the mouseover effect to work with both ie and firefox I currently must duplicate the attributes.



Is there some way to assign both the alt and title attributes to the same value short of retyping the attribute description

2006-10-27 04:18:43 · 2 answers · asked by Interested Dude 7 in Computers & Internet Programming & Design

2 answers

You can use the Document Object Module to dynamically set the title to equal the alt attribute, but it likely isn't worth the effort.

In javascript you can create an array of all the images on the page. Then loop thru the images. For each image if the alt attribute isn't empty or null (for spacer images and such), set the title attribute of each image to equal the alt attribute of the image.

Definitely assign an alt attribute to each image for accessibility, and then use the js to add the title effect, not the other way around.

Let me know if you need more explanation.

2006-10-29 12:12:51 · answer #1 · answered by ★ Estelle ★ 6 · 0 0

I don't believe so, they are 2 different attributes and therefore must be typed separately. The easiest thing to do would probably be to just copy the text and paste it to save some typing.

2006-10-27 11:25:43 · answer #2 · answered by Yoi_55 7 · 0 0

fedest.com, questions and answers