In this lesson, we will be going over the attribute aria-expanded. Instead of using a class like .open we are going to use the aria-expanded attribute to style.

This accomplished double duty because we have semantic value and visual indicators that a button is open and closed.

To test this, I opened up Safari and used CMD + F5 to turn VoiceOver on.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="css/style.css" />
<title>Egghead Aria Expanded</title>
</head>
<body>
<h1>Aria Expanded Demo</h1>
<button class="pop-up__open">Helpful links</button>
<ul class="pop-up__items">
<li>
<a href="http://google.com/">Google</a>
</li>
<li>
<a href="http://google.com/">Stack Overflow</a>
</li>
<li>
<a href="https://dev.to/">Dev.to</a>
</li>
</ul>
<script>
const showButton = document.querySelector(".pop-up__open");
showButton.setAttribute("aria-expanded", false); showButton.addEventListener("click", () => {
const ariaExpanded = showButton.getAttribute("aria-expanded"); // This will return a string if (ariaExpanded === "true") {
showButton.setAttribute("aria-expanded", false);
} else {
showButton.setAttribute("aria-expanded", true);
}
});
</script>
</body>
</html>

  

[ARIA] Add aria-expanded to add semantic value and styling的更多相关文章

  1. 在 VS 类库项目中 Add Service References 和 Add Web References 的区别

    原文:在 VS 类库项目中 Add Service References 和 Add Web References 的区别 出身问题: 1.在vs2005时代,Add Web Reference(添加 ...

  2. git add -A 和 git add . 的区别

    git add -A和 git add .   git add -u在功能上看似很相近,但还是存在一点差别 git add . :他会监控工作区的状态树,使用它会把工作时的所有变化提交到暂存区,包括文 ...

  3. git add -A和git add . 的区别

    git add -A和 git add . git add -u在功能上看似很相近,但还是有所差别. git add . :他会监控工作区的状态树,使用它会把工作时的所有变化提交到暂存区,包括文件内容 ...

  4. add jars、add external jars、add library、add class folder的区别

    add external jars = 增加工程外部的包add jars = 增加工程内包add library = 增加一个库add class folder = 增加一个类文件夹 add jar是 ...

  5. xtu summer individual 5 A - To Add or Not to Add

    To Add or Not to Add Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeFo ...

  6. git add -A、git add -u、git add .区别

    git add各命令及缩写 git add各命令 缩写 git add --all git add -A git add --update git add -u git add . Git Versi ...

  7. 函数柯里化常见应用---add(1,2) add(1)(2) add(1)(2)(3) add(1,2,3)(4)

    这是一道经典的题目,先上代码: 解法1: function add () { var args = Array.prototype.slice.call(arguments); var fn = fu ...

  8. windows下SVN使用 Add指令、Undo Add指令

    前几天,使用SVN的Add指令添加了一个文件,后不使用直接删除了,每次提交都存在,解决后记录方法,希望帮到大家,此外如果大家有好的方法,希望可以回复. 问题:使用Add添加文件后直接删除了文件,每次提 ...

  9. git的常用指令(二) git add -A 、git add . 和 git add -u

    git add . :他会监控工作区的状态树,使用它会把工作时的所有变化提交到暂存区,包括文件内容修改(modified)以及新文件(new),但不包括被删除的文件. git add -u :他仅监控 ...

随机推荐

  1. Go基础编程实践(十)—— 数据库

    从数据库中读取数据 在http://sqlitebrowser.org/下载sqlite3可视化工具,在本main.go同目录下创建personal.db数据库,创建表如下: package main ...

  2. MySql5.7 json查询

    create table t1(name json); insert into t1 values(’ { “hello”: “song”, “num”: 111, “obj”: { “who”: “ ...

  3. java基础 Math

    package cn.mantishell.day08.demo04; /** * java.util.Math类是数学相关的工具类,里面提供类大量的静态方法,完成与数学运算相关的操作 * * pub ...

  4. 去掉a标签点击后的虚边框

    a { cursor: pointer; text-decoration: none; hide-focus: expression(this.hideFocus=true); outline: no ...

  5. Nikitosh 和异或(trie树)

    题目: #10051. 「一本通 2.3 例 3」Nikitosh 和异或 解析: 首先我们知道一个性质\(x\oplus x=0\) 我们要求\[\bigoplus_{i = l}^ra_i\]的话 ...

  6. sdcard不可执行.

    Possibly you placed it on your sdcard -- which is mounted with the noexec flag. You either need to m ...

  7. Vue学习之webpack调用第三方loader(十五)

    ---恢复内容开始--- 一.webpack 默认只能打包处理 JS 类型的文件,无法处理 其他的非  JS 类型的文件: 如果非要处理 非 JS 类型的文件,我们需要手动安装一些 合适 第三方 lo ...

  8. DataPipeline CTO 陈肃:我们花了3年时间,重新定义数据集成

    目前,中国企业在大数据流通.交换.利用等方面仍处于起步阶段,但是企业应用数据集成市场却是庞大的.根据 Forrester 数据看来,2017 年全球数据应用集成市场纯软件规模是 320 亿美元,如果包 ...

  9. VSCode 控制台面板输出乱码 字符编码问题 PHP --已解决

    首先上一张效果图,看看是不是你想要的效果. 第一步: 按F1,输入settings.json,添加 "code-runner.runInTerminal": true, 第二步:将 ...

  10. 嵌入式LINUX启动时间优化

    1. 实践过程 我是对海思3559进行启动时间优化的.具体的操作可以参考<Hi3559V100/Hi3556V100 快速启动优化指南>.软件上启动时间的优化一般是从三方面进行的:ubbo ...