HTMLInputElement: thuộc tính defaultChecked
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 defaultChecked của giao diện HTMLInputElement 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 checked của phần tử <input>.
Thuộc tính boolean checked hợp lệ cho các loại đầu vào radio (<input type="radio">) và checkbox (<input type="checkbox">). Sự hiện diện của thuộc tính đặt thuộc tính defaultChecked thành true.
Giá trị
Một boolean.
Ví dụ
js
const inputElement = document.getElementById("contactMail");
console.log(inputElement.defaultChecked);
Đặc tả kỹ thuật
| Specification |
|---|
| HTML> # dom-input-defaultchecked> |