คุณสมบัติสูงสุดของ HTML DOM Input Week max ส่งกลับ/ตั้งค่าแอตทริบิวต์สูงสุดของสัปดาห์อินพุต
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
- คืนค่าสตริง
inputWeekObject.max
- การตั้งค่า สูงสุด เป็นค่าสตริง
inputWeekObject.max = YYYY-Www
ค่าสตริง
ที่นี่ “ปปปป-Www” สามารถเป็นดังต่อไปนี้ -
| stringValue | รายละเอียด |
|---|---|
| ปปปป | มันกำหนดปี (เช่น:2017) |
| W | เป็นตัวคั่นสำหรับปีและสัปดาห์ |
| ww | กำหนดสัปดาห์ (เช่น:52) |
ตัวอย่าง
ให้เรามาดูตัวอย่างสำหรับ Input Week max ทรัพย์สิน −
<!DOCTYPE html>
<html>
<head>
<title>Input Week max</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-max</legend>
<label for="WeekSelect">Ongoing Week:
<input type="week" id="WeekSelect" value="2020-W01" max="2019-W52" disabled>
</label>
<input type="button" onclick="renewInsurance()" value="Renew Insurance">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputWeek = document.getElementById("WeekSelect");
divDisplay.textContent = 'Insurance Expired as of: Week'+inputWeek.max.split("-W")[1];
divDisplay.textContent += ' ,'+inputWeek.max.split("-W")[0];
function renewInsurance() {
inputWeek.max = '2029-W52';
divDisplay.textContent = 'Insurance Renewed till: Week'+inputWeek.max.split("-W")[1];
divDisplay.textContent += ' ,'+inputWeek.max.split("-W")[0];
}
</script>
</body>
</html> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
ก่อนคลิก 'ต่ออายุประกัน' ปุ่ม −

หลังจากคลิก 'ต่ออายุประกัน' ปุ่ม −
