HTML DOM Input Week max 属性
htmlweb developmentfront end technology更新于 2025/9/5 2:52:17
HTML DOM Input Week max 属性返回/设置 Input Week 的 max 属性。
语法
以下是语法 −
- 返回字符串值
inputWeekObject.max
- 将 max 设置为字符串值
inputWeekObject.max = YYYY-Www
字符串值
此处,“YYYY-Www” 可以是以下 −
| stringValue | 详细信息 |
|---|---|
| YYYY | 定义年份 (例如: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>
输出
这将产生以下输出 −
点击"续保"按钮前 −

点击"续保"按钮后 −

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

