Thuộc tính kiểu DatetimeLocal đầu vào HTML DOM trả về / đặt loại kiểu DatetimeLocal đầu vào.
Cú pháp
Sau đây là cú pháp -
- Giá trị chuỗi trả về
inputDatetimeLocalObject.type
- Cài đặt loại thành giá trị chuỗi
inputDatetimeLocalObject.type = stringValue
Giá trị chuỗi
Đây, “stringValue” có thể như sau -
| stringValue | Chi tiết |
|---|---|
| ngày | Nó xác định loại đầu vào là ngày |
| datetime-local | Nó xác định loại đầu vào là datetime-local |
| hộp kiểm | Nó xác định loại đầu vào là hộp kiểm |
| văn bản | Nó xác định loại đầu vào là văn bản |
Ví dụ
Hãy để chúng tôi xem một ví dụ về Nhập kiểu DatetimeLocal tài sản -
<!DOCTYPE html>
<html>
<head>
<title>Input DatetimeLocal type</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>Datetime-Local-type</legend>
<label for="datetimeLocalSelect">Inauguration Date-Time :
<input type="datetime-local" id="datetimeLocalSelect" value="2020-01-01T10:00">
</label>
<input type="button" onclick="getEvent()" value="Where is the event? ">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputDatetimeLocal = document.getElementById("datetimeLocalSelect");
function getEvent() {
if(inputDatetimeLocal.type === 'datetime-local')
divDisplay.textContent = 'Event Inauguration near you';
else
divDisplay.textContent = 'Event Inauguration in India';
}
</script>
</body>
</html> Đầu ra
Điều này sẽ tạo ra kết quả sau -
Trước khi nhấp vào ‘Sự kiện ở đâu?’ nút -
Sau khi nhấp vào ‘Sự kiện ở đâu?’ nút -