简体   繁体   English

javascrpit 不使用 aria-label 显示为空

[英]javascrpit not working with aria-label show empty

Before Click Button点击按钮前

<button type="button" class="plyr__control" data-plyr="play" aria-label="Play">

After Click Button点击按钮后

<button type="button" class="plyr__control plyr__control--pressed" data-plyr="play" aria-label="Pause">

My Script我的脚本

 <script> const $featured = $('.plyr__control'); // bind a change event handler to the input $featured.on('change', function() { if (button.getAttribute('aria-label') === 'Pause') { console.log('ok'); } }); </script>

Here JavaScript is not working. JavaScript 在这里不起作用。 How to solve this?如何解决这个问题?

Written by ( Carlos Moore ) and the rich skills Staff.由 ( Carlos Moore ) 和技能丰富的员工撰写。

aria-label咏叹调标签

An interactive element's label is defined by the string value of the aria-label property.交互式元素的标签由 aria-label 属性的字符串值定义。

There may be no visible content in the DOM that can be associated with the object to give it meaning when the element's default accessible name is absent or inaccurately describes its contents.当元素的默认可访问名称不存在或不准确地描述其内容时,DOM 中可能没有可以与对象关联的可见内容以赋予其意义。 A typical illustration is a button with no text and an SVG or icon font (which you shouldn't be using).一个典型的插图是一个没有文本的按钮和一个 SVG 或图标字体(你不应该使用)。

The aria-label attribute can be used to define a string that labels the interactive element on which it is set when an interactive element lacks an accessible name or has an inaccurate accessible name and no visible content in the DOM that can be linked via the aria-labelledby attribute. aria-label 属性可用于定义一个字符串,当交互元素缺少可访问名称或具有不准确的可访问名称且 DOM 中没有可通过 aria 链接的可见内容时,该字符串标记设置它的交互元素-labelledby 属性。 This provides the element with its accessible name.这为元素提供了可访问的名称。

<button aria-label="Close" onclick="myDialog.close()">
      <svg aria-hidden="true" focusable="false" width="20" height="20" xmlns="http://www.w3.org/2000/svg"><path d="m.967 14.217 5.8-5.906-5.765-5.89L3.094.26l5.783 5.888L14.66.26l2.092 2.162-5.766 5.889 5.801 5.906-2.092 2.162-5.818-5.924-5.818 5.924-2.092-2.162Z" fill="#000"/></svg</button>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在按钮上添加 aria-label - Add aria-label on button 带有aria标签的猫头鹰轮播2.2点 - owl carousel 2.2 dots with aria-label 使用xpath单击aria-label元素 - Click a aria-label element using xpath Substring 数组的所有 aria-label 元素 - Substring all aria-label elements of an array 如何定位元素<div aria-label></div><div id="text_translate"><p>我在 selenium java 中非常初级。 我正在尝试在亚马逊中找到该元素。</p><p> 当我尝试运行此代码时,我找不到该元素。 请帮助解决这个问题。</p><p> <a href="https://i.stack.imgur.com/eMWTB.png" rel="nofollow noreferrer">在此处输入图像描述</a></p><p>这是我的代码</p><pre> WebElement a_review= driver.findElement(By.xpath("//div[@aria-label='4 Stars &amp; Up']")); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", a_review); a_review.click();</pre></div> - how to locate the element in <div aria-label> 将 aria-label 添加到数据表中的表 header - Add aria-label to table header in datatable NVDA无法读取带有aria标签描述的aria - NVDA doesn't read aria-describedby with aria-label aria-label 和 aria-labelledby 的区别 - Difference between aria-label and aria-labelledby 使用键盘导航时无法读取aria-label属性 - aria-label attribute not being read when navigating using keyboard 如果以“示例”开头,我如何调用 aria-label - How can i call aria-label if it start with "Example"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM