<分区>
我尝试使用 ARIA 选择页面上的所有元素属性以检查页面是否错误使用了它们。 众所周知,该属性以 aria-[NAME] 开头。
因为我不能使用 regex带有元素选择器,以及 css selectors没有给我通配符选择属性名称的选项(或者是吗?),我想知道我该怎么做?
简单测试页:
<div id="percent-loaded" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" ></div>
<div class="text">
<label id="tp1-label" for="first">First Name:</label>
<input type="text" id="first" name="first" size="20" aria-labelledby="tp1-label" aria-describedby="tp1" aria-required="false" />
<div id="tp1" class="tooltip" role="tooltip" aria-hidden="true">Your first name is optional</div>
</div>
<script>
let elAria1 = document.querySelectorAll('[aria-*]'); // this doesn't work
let elAria2 = document.querySelectorAll('[aria-'*]); // this doesn't work either
let elAria3 = document.querySelectorAll([aria-*]); // this doesn't work too
</script>