Element: thuộc tính ariaPressed
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 ariaPressed của giao diện Element phản chiếu giá trị của thuộc tính aria-pressed, cho biết trạng thái "đã nhấn" hiện tại của nút bật/tắt.
Giá trị
Một chuỗi với một trong các giá trị sau:
"true"-
Phần tử đang được nhấn.
"false"-
Phần tử hỗ trợ được nhấn nhưng hiện tại chưa được nhấn.
"mixed"-
Cho biết giá trị chế độ hỗn hợp cho nút bật/t tắt ba trạng thái.
"undefined"-
Phần tử không hỗ trợ được nhấn.
Ví dụ
Trong ví dụ này, thuộc tính aria-pressed trên phần tử có ID saveChanges được đặt thành "false" cho biết đầu vào này hiện đang không được nhấn. Sử dụng ariaPressed chúng ta cập nhật giá trị thành "true".
html
<div id="saveChanges" tabindex="0" role="button" aria-pressed="false">Save</div>
js
let el = document.getElementById("saveChanges");
console.log(el.ariaPressed); // "false"
el.ariaPressed = "true";
console.log(el.ariaPressed); // "true"
Đặc tả kỹ thuật
| Specification |
|---|
| Accessible Rich Internet Applications (WAI-ARIA)> # dom-ariamixin-ariapressed> |