E-mail List Archives
Regarding images lacking alts
From: Bryan Garaventa
Date: Dec 4, 2012 2:26PM
- Next message: Jukka K. Korpela: "Re: Regarding images lacking alts"
- Previous message: Duff Johnson: "Re: EC proposes rules to make government websites accessible for all"
- Next message in Thread: Jukka K. Korpela: "Re: Regarding images lacking alts"
- Previous message in Thread: None
- View all messages in this Thread
Hi, I still experience this all over the place on the web, and it's sort of annoying.
Here is a jQuery script that fixes it dynamically, though in a perfect world, it wouldn't be needed.
$('img').each(function(i, o){
var hasAlt = o.getAttributeNode('alt') ? true : false,
hasTitle = o.getAttributeNode('title') ? true : false;
if (!hasAlt) $(o).attr('alt', hasTitle ? o.title : '');
});
It can also be changed to throw an alert during development, such as
if (!hasAlt) alert("Missing Alt attribute: " + o.outerHTML);
- Next message: Jukka K. Korpela: "Re: Regarding images lacking alts"
- Previous message: Duff Johnson: "Re: EC proposes rules to make government websites accessible for all"
- Next message in Thread: Jukka K. Korpela: "Re: Regarding images lacking alts"
- Previous message in Thread: None
- View all messages in this Thread