Thuộc tính Thời gian nhập DOM bị vô hiệu hóa sẽ đặt / trả về liệu Thời gian nhập liệu được bật hay tắt.
Cú pháp
Sau đây là cú pháp -
- Trả về giá trị boolean - true / false
inputTimeObject.disabled
- Đã tắt cài đặt thành booleanValue
inputTimeObject.disabled = booleanValue
Giá trị Boolean
Đây, “booleanValue” có thể như sau -
| booleanValue | Chi tiết |
|---|---|
| true | Nó xác định rằng thời gian đầu vào bị vô hiệu hóa. |
| sai | Nó xác định rằng thời gian đầu vào không bị vô hiệu hóa và nó cũng là giá trị mặc định. |
Ví dụ
Hãy để chúng tôi xem ví dụ về Thời gian nhập liệu bị tắt tài sản -
<!DOCTYPE html>
<html>
<head>
<title>Input Time disabled</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Time-disabled</legend>
<label for="TimeSelect">Meeting At:
<input type="time" id="TimeSelect" value="15:10">
</label>
<input type="button" onclick="confirmMeet()" value="Confirm Meeting">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputTime = document.getElementById("TimeSelect");
function confirmMeet() {
inputTime.disabled = true;
divDisplay.textContent = 'Meeting fixed at : '+inputTime.value;
}
</script>
</body>
</html> Đầu ra
Điều này sẽ tạo ra kết quả sau -
Trước khi nhấp vào ‘Xác nhận cuộc họp’ nút -
Sau khi nhấp vào ‘Xác nhận cuộc họp’ nút -