[AngularJS] Accessible Button Events

Often buttons need to be handled by JavaScript, and if done improperly it can lead to accessibility issues. In this lesson you will improve a major news organization‘s global header with some basic HTML and JavaScript.

Normal you should use native ‘button‘ to make a button instead of use other html element to make a button, then you can access the button thought the keyboard.

If you use a ‘div‘, then what you should do to make it accessible to the user by keyborad, you should add ‘role‘, ‘tabindex‘ & ‘aria-label‘ to it:

<button aria-label="Help">
    <i class="icon icon-help"></i>
</button>

<div class="button" role="button" tabindex="0" aria-label="Menu">
    <i class="icon icon-menu"></i>
</div>

If you use AngularJS,and you want press ‘Enter‘ to get the handle event, you should add ‘ng-keydown‘ for it:

<button aria-label="Help" ng-click="doStuff()">
    <i class="icon icon-help"></i>
</button>

<div class="button" role="button" tabindex="0" aria-label="Menu" ng-click="doStuff()" ng-keydown="doStuff()">
    <i class="icon icon-menu"></i>
</div>
时间: 2024-10-09 22:07:46

[AngularJS] Accessible Button Events的相关文章

Part 39 AngularJS route change events

In this video we will discuss1. Different events that are triggered when a route change occurs in an angular application2. Logging the events and event handler parameters to inspect their respective properties When route navigation occurs in an Angul

Document Object Model (DOM) Level 3 Events Specification

Document Object Model (DOM) Level 3 Events Specification W3C Working Draft 25 September 2014 This version: http://www.w3.org/TR/2014/WD-DOM-Level-3-Events-20140925/ Latest published version: http://www.w3.org/TR/DOM-Level-3-Events/ Latest editor's dr

AngularJs MVC 详解

为什么在前端也需要MVC 1.代码规模越来越大,切分职责是大势所趋 2.为了复用 3.为了后期维护方便 MVC的目的是为了模块化和复用 前端实现MVC的困难 1.操作DOM必须等整个页面加载完 2.多个js如果出现依赖,需要程序员自己解决 3.js的原型继承 Controller 需求:有一些功能,在各个控制器中都会用到,怎么办? 1 <!DOCTYPE html> 2 <html lang="en" ng-app="myApp"> 3 &l

AngularJS的控制器示例

代码下载:https://files.cnblogs.com/files/xiandedanteng/angularjsCtrl.rar 代码: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html ng-app="notesApp"> <head>

Corona手游教程之widget:Button篇

在corona sdk里,创建界面交互元素widget,非常方便灵活,并且具备极强的可定制性. 我们创建按钮使用如下代码: widget.newButton( options ) 我们有多种方式来创建按钮,不管哪一种,options都可以包含的公共字段如下: id:(可选)一个关联到此按钮的可选的字符串标识,默认为”widget_button“ x, y:(可选)origin坐标 left, top:(可选)左上角坐标 isEnable:是否启用,默认为true.通过button:setEnab

C# - Events Tutorial

This tutorial shows how to declare, invoke, and hook up to events in C#. Tutorial An event in C# is a way for a class to provide notifications to clients of that class when some interesting thing happens to an object. The most familiar use for events

[转]雅虎加速网站最佳实践

转自:Best Practices for Speeding Up Your Web Site Best Practices for Speeding Up Your Web Site The Exceptional Performance team has identified a number of best practices for making web pages fast. The list includes 35 best practices divided into 7 cate

Best Practices for Speeding Up Your Web Site

The Exceptional Performance team has identified a number of best practices for making web pages fast. The list includes 35 best practices divided into 7 categories. Looking to optimize your mobile app experience? Check out Flurry Analytics. Filter by

Web 站点提速的最佳实践(Best Practices for Speeding Up Your Web Site)

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. Best Practices for Speeding Up Your Web Site The Exceptional Performance