WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Regarding images lacking alts

for

From: David Ashleydale
Date: Dec 4, 2012 2:38PM


Cool.

Now run it on every web site everywhere. Go!

It might be nice if there were beneficial computer viruses. We could call
them computer "antidotes".

David


On Tue, Dec 4, 2012 at 1:26 PM, Bryan Garaventa <
<EMAIL REMOVED> > wrote:

> 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);
> > > >