Phương thức stepDown() của đối tượng Input DatetimeLocal giảm giá trị ngày giờ đi một số phút xác định (mặc định 1 phút).
Cú pháp
inputDatetimeLocalObject.stepDown(số_phút)
Ví dụ minh họa
Giảm ngày giờ cục bộ 10 phút hoặc 25 phút:
<!DOCTYPE html>
<html>
<head>
<title>Input DatetimeLocal stepDown()</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-stepDown()</legend>
<label for="datetimeLocalSelect">Ngày giờ cục bộ: <input type="datetime-local" id="datetimeLocalSelect" value="2010-12-21T23:50"> </label>
<input type="button" onclick="changeStep(10)" value="Giảm 10 phút">
<input type="button" onclick="changeStep(25)" value="Giảm 25 phút">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputDatetimeLocal = document.getElementById("datetimeLocalSelect");
function changeStep(myStepDown) {
inputDatetimeLocal.stepDown(myStepDown);
divDisplay.textContent = 'Bước giảm: ' + myStepDown + ' phút';
}
</script>
</body>
</html>
Kết quả
Giá trị ban đầu 23:50. Nhấn "Giảm 10 phút" -> 23:40. Nhấn "Giảm 25 phút" -> 23:25.