Element: thuộc tính ariaSelected
Baseline
2023
Newly available
Since October 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Thuộc tính ariaSelected của giao diện Element phản ánh giá trị của thuộc tính aria-selected, cho biết phần tử con của phần tử hiện tại có được chọn hay không.
Giá trị
Một chuỗi có giá trị "true" hoặc "false".
Ví dụ
Trong ví dụ này, thuộc tính aria-selected trên phần tử có ID là selected-item được đặt là "true". Sử dụng ariaSelected, chúng ta cập nhật giá trị thành "false".
html
<div role="listbox">
<div role="option" id="selected-item" aria-selected="true">
Mục đã chọn
</div>
<div role="option">Mục chưa chọn</div>
</div>
js
let el = document.getElementById("selected-item");
console.log(el.ariaSelected); // "true"
el.ariaSelected = "false";
console.log(el.ariaSelected); // "false"
Đặc tả kỹ thuật
| Specification |
|---|
| Accessible Rich Internet Applications (WAI-ARIA)> # dom-ariamixin-ariaselected> |