【发布时间】:2020-10-04 18:07:09
【问题描述】:
我有以下无法更改的 HTML(我无法影响的公司工具的一部分)。这是一个下拉菜单,我想在 Tampermonkey 脚本中使用 Javascript/JQuery 访问下拉菜单中的所有值(链接):
<div class="ant-select-selection ant-select-selection--single" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-controls="e80ef4e8-f947-4351-88b3-136bb5f3d62f" aria-expanded="false" tabindex="0">
<div class="ant-select-selection__rendered"><div class="ant-select-selection-selected-value" title="6 - Live" style="display: block; opacity: 1;">6 - Live</div></div>
<div class="ant-select-selection-selected-value" title="6 - Live" style="display: block; opacity: 1;">6 - Live</div>
</div>
最终目标:添加一个按钮,只需单击即可从下拉列表中打开 5 个链接
我尝试了什么:
document.getElementsByClassName("ant-select-selection"):返回“未定义” document.querySelector("combobox"):返回“未定义”
我的理解
我知道当我点击下拉菜单时,
aria-expanded="false"
更改为“true”和新类
ant-select-open, ant-select-focussed, ant-select-enabled
正在对元素。将 evenListener 添加到单击下拉列表并尝试在单击后访问值也不起作用(仅返回下拉列表的选定值,而不是全部)
但我不知道如何利用它来访问所有下拉值。
简而言之,我的问题:如何访问 aria 组合框下拉元素的值?
【问题讨论】:
标签: javascript html jquery combobox wai-aria