HTMLOptionElement: thuộc tính label
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thuộc tính label của HTMLOptionElement đại diện cho văn bản hiển thị cho một tùy chọn trong phần tử <select> hoặc là một phần của danh sách gợi ý trong phần tử <datalist>. Nó phản ánh thuộc tính label của phần tử <option>.
Nếu thuộc tính bị bỏ qua hoặc là chuỗi rỗng, thuộc tính label trả về nội dung text của phần tử.
Giá trị
Một chuỗi.
Ví dụ
js
const optionElement = document.getElementById("exampleOption");
console.log(`Nhãn tùy chọn: ${optionElement.label}`);
optionElement.label = "Nhãn đã cập nhật";
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| HTML> # dom-option-label> |