Element: thuộc tính ariaPlaceholder

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 ariaPlaceholder của giao diện Element phản chiếu giá trị của thuộc tính aria-placeholder, định nghĩa một gợi ý ngắn nhằm hỗ trợ người dùng nhập liệu khi điều khiển không có giá trị.

Note: Khi có thể, hãy sử dụng phần tử HTML <input> với type="text" hoặc <textarea> vì chúng có ngữ nghĩa tích hợp sẵn và không yêu cầu thuộc tính ARIA.

Giá trị

Một chuỗi.

Ví dụ

Trong ví dụ này, thuộc tính aria-placeholder trên phần tử có ID txtBoxInput đã được đặt thành một chuỗi. Sử dụng ariaPlaceholder chúng ta cập nhật chuỗi thành một giá trị khác.

html
<div id="txtboxLabel">Enter your five-digit zip code</div>
<div
  role="textbox"
  id="txtBoxInput"
  contenteditable="true"
  aria-placeholder="5-digit zip code"
  aria-labelledby="txtboxLabel"></div>
js
let el = document.getElementById("txtBoxInput");
console.log(el.ariaPlaceholder); // "5-digit zip code"
el.ariaPlaceholder = "12345";
console.log(el.ariaPlaceholder); // "12345"

Đặc tả kỹ thuật

Specification
Accessible Rich Internet Applications (WAI-ARIA)
# dom-ariamixin-ariaplaceholder

Tương thích trình duyệt

Xem thêm