Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Inclusive Javascript

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

Inclusive Javascript

Quick fixes to make interactive sites more accessible to people with disabilities

Avatar for Julie Grundy

Julie Grundy

August 05, 2017

Other Decks in Technology

Transcript

  1. Basic accessible button <div class=“btn btn-primary” id=“myButton” tabindex=“0” role=“button”>Click Me</div>

    myButton.click(function(){ console.log(“I’ve been clicked!”); }); myButton.keypress(function(e){ if (keycode == 13) { console.log(“I’ve been clicked by the Enter key!”); } });
  2. Basic accessible button <div class=“btn btn-primary” id=“myButton” tabindex=“0” role=“button”>Click Me</div>

    myButton.click(function(){ console.log(“I’ve been clicked!”); }); myButton.keypress(function(e){ if (keycode == 13) { console.log(“I’ve been clicked by the Enter key!”); } }); myButton.keypress(function(e) { if (keycode == 32) { console.log(“I’ve been clicked by the spacebar!”); } });
  3. Semantic HTML helps achieve device independence <div class=“wrapper”> <div class=“heading

    heading1”>City Farmers, Belmont</div> <div class=“summary”>Leading provider of bulk pet and garden supplies. <a href=“www.cityfarmers.com.au/belmont”>Visit Website</a></div> <div class=“rating-summary”><span>4.5/5 stars</span><span>32 reviews</span><span><a href=“www.google.com/fj5qp23984ht/”>Review on Google</a></span></div> <div class=“btn”>Open in Google Maps</div> </div>
  4. Semantic HTML helps achieve device independence <div class=“wrapper”> <h1>City Farmers,

    Belmont</h1> <p>Leading provider of bulk pet and garden supplies. <a href=“www.cityfarmers.com.au/belmont”>Visit Website</a></p> <ul> <li>4.5/5 stars</li> <li>32 reviews</li> <li><a href=“www.google.com/fj5qp23984ht/”>Review on Google</a></li> </ul> <button>Open in Google Maps</button> </div>
  5. Focus management <p id=“dataSummary” tabindex=“-1”>…</p> <button id=“myButton”>Sort A to Z</button>

    myButton.addEventListener(“click”, function(event){ dataSummary.focus(); }, false);
  6. Focus management <p id=“dataSummary” tabindex=“-1”>…</p> <button id=“myButton”>Sort A to Z</button>

    myButton.addEventListener(“click”, function(event){ dataSummary.focus(); }, false); <a href=“#transcript”>Show Transcript</a>
  7. ARIA Live Updates <div id=“myBag” aria-live=“polite” aria-atomic=“true”> <a href=“shoppingbag.html”>My Bag

    <span id=“bagCount”>1</span> <span class=“visually-hidden”>item added</span> </a> </div>
  8. ARIA Live Updates <form> <label for=“memNum”>Member ID:</label> <input type=“text” id=“memNum”>

    <button type=“submit”>Log In</button> <p class=“error”>This is not a valid ID</p> </form>
  9. ARIA Live Updates <form> <label for=“memNum” aria-labelledby=“loginerror”>Member ID:</label> <input type=“text”

    id=“memNum”> <button type=“submit”>Log In</button> <p class=“error” id=“loginerror”>This is not a valid ID</p> </form>
  10. Don’t use ARIA • Thoughtfully • For scripted events •

    Which aren’t easily explainable with just HTML/CSS