Thuộc tính tối thiểu Tuần nhập liệu HTML DOM trả về / đặt thuộc tính tối thiểu của Tuần nhập liệu.
Cú pháp
Sau đây là cú pháp -
- Giá trị chuỗi trả về
inputWeekObject.min
- Cài đặt tối thiểu thành giá trị chuỗi
inputWeekObject.min = YYYY-Www
Giá trị chuỗi
Đây, “YYYY-Www” có thể như sau -
| stringValue | Chi tiết |
|---|---|
| YYYY | Nó xác định năm (ví dụ:1990) |
| W | Đây là dấu phân cách giữa năm và tuần |
| ww | Nó xác định tuần (ví dụ:07) |
Ví dụ
Hãy để chúng tôi xem một ví dụ về Tối thiểu của tuần nhập liệu tài sản -
<!DOCTYPE html>
<html>
<head>
<title>Input Week min</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>Week-min</legend>
<label for="WeekSelect">Vacation Week:
<input type="week" id="WeekSelect" value="2019-W45" min="2020-W05">
</label>
<input type="button" onclick="getMinimum()" value="Go on a vacation">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputWeek = document.getElementById("WeekSelect");
function getMinimum() {
divDisplay.textContent = 'You can go on a vacation after: Week: '+inputWeek.min.split("-W")[1]+' ,'+inputWeek.min.split("-W")[0]
}
</script>
</body>
</html> Đầu ra
Điều này sẽ tạo ra kết quả sau -
Trước khi nhấp vào ‘Đi nghỉ’ nút -
Sau khi nhấp vào ‘Đi nghỉ mát’ nút -