WebAIM - Web Accessibility In Mind

E-mail List Archives

speaking string when element gets focus?

for

From: Alex Hall
Date: May 11, 2016 1:12PM


Hey all,
I was just wondering if there's a way to have a string spoken when focus
lands on a certain element. For instance, I have a webpage that displays
the results of a database lookup. It color-codes the table rows--red for
errors in the shipment, blue for overweight boxes, etc. It struck me that
having the screen reader say "has errors" when focus lands on a row with
errors, for instance, would be useful for me.

My first thought is something like:
$("tr.hasErrors").on("focus", function() {
$(divForSpeaking).val("has errors");
});

But I don't know if that would do what I'm after. I don't want this per
cell, only per row. That is, if I move to the row, no matter on which cell
I land, I'd hear "has errors". As I move from cell to cell within that row,
though, I hear nothing. I also don't know if there's a better way to do
this, something like an img tag's alt attribute, but for screen readers to
speak when they land on an item?

--
Alex Hall
Automatic Distributors, IT department
<EMAIL REMOVED>