HTMLOptionElement: thuộc tính defaultSelected

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 defaultSelected của giao diện HTMLOptionElement xác định trạng thái được chọn mặc định của phần tử. Thuộc tính này phản ánh thuộc tính selected của phần tử <option>. Sự hiện diện của thuộc tính selected đặt thuộc tính defaultSelected thành true.

Giá trị

Một giá trị boolean.

Ví dụ

js
const optionElement = document.getElementById("water");
console.log(optionElement.defaultSelected);

Thông số kỹ thuật

Specification
HTML
# dom-option-defaultselected

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

Xem thêm