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>

  

最新文章

  1. 从零开始学Python第七周:面向对象进阶(需修改)
  2. 标准W3C盒子模型和IE盒子模型
  3. WxInput模块则比较彻底的解决了这个问题
  4. hdu 1250 Hat&#39;s Fibonacci
  5. PHP中的cookie
  6. FileZilla无法确定拖放操作的目标,由于shell未正确安装
  7. Android的横竖屏切换
  8. C++----练习--while求和
  9. centos5.8本地安装yum资源,安装软件包
  10. JS中encodeURI,escape,encodeURIComponent区别
  11. java读取请求中body数据
  12. Request和Response
  13. MySQL 8 新特性之持久化全局变量的修改
  14. 关于BDD100k数据输入处理mask变为56*56
  15. 一起学习造轮子(一):从零开始写一个符合Promises/A+规范的promise
  16. flutter学习地址
  17. 在Java中动态传参调用Python脚本
  18. [Java in NetBeans] Lesson 05. Method/function
  19. 几种常见数据库的driverClassName和url
  20. Educational Codeforces Round 61 F 思维 + 区间dp

热门文章

  1. thinkphp 5.0.24 配置多模块注意的细节
  2. 【论文排版工具】——LaTeX的安装及使用(MiKTeX+TexStudio+Windows)
  3. 第2课,python while循环的使用
  4. 一句话比较两种算法的优越性[蓝桥杯,LeetCode]
  5. golang http及其他标准库
  6. Scala 安装 Scala for Eclipse安装及运行hello word
  7. kibana内存设置
  8. ELK学习笔记之logstash将配置写在多个文件
  9. C# 运行流程
  10. 1 matplotlib绘制折线图