E-mail List Archives
Re: Regarding images lacking alts
From: David Ashleydale
Date: Dec 4, 2012 2:38PM
- Next message: Jared Smith: "Re: Regarding images lacking alts"
- Previous message: Jukka K. Korpela: "Re: Regarding images lacking alts"
- Next message in Thread: Jared Smith: "Re: Regarding images lacking alts"
- Previous message in Thread: Jukka K. Korpela: "Re: Regarding images lacking alts"
- View all messages in this Thread
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);
> > > >
- Next message: Jared Smith: "Re: Regarding images lacking alts"
- Previous message: Jukka K. Korpela: "Re: Regarding images lacking alts"
- Next message in Thread: Jared Smith: "Re: Regarding images lacking alts"
- Previous message in Thread: Jukka K. Korpela: "Re: Regarding images lacking alts"
- View all messages in this Thread