HTML DOM 입력 월 min 속성은 HTML 문서에서 type="month" 입력 필드의 min 속성 값을 반환하고 수정합니다.
구문
다음은 구문입니다 -
1. 최소 반환
object.min
2. 최소 수정
object.min = “YYYY-MM”
여기서 YYYY는 연도를 나타내고 MM은 "2019-02"와 같이 월을 나타냅니다.
예시
HTML DOM 입력 월 최소 속성의 예를 살펴보겠습니다 -
<!DOCTYPE html>
<html>
<head>
<style>
html{
height:100%;
}
body{
text-align:center;
color:#fff;
background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%)
center/cover no-repeat;
height:100%;
}
p{
font-weight:700;
font-size:1.1rem;
}
input{
display:block;
width:35%;
border:2px solid #fff;
background-color:transparent;
color:#fff;
font-weight:bold;
padding:8px;
margin:1rem auto;
}
.btn{
background:#0197F6;
border:none;
height:2rem;
border-radius:2px;
width:35%;
margin:2rem auto;
display:block;
color:#fff;
outline:none;
cursor:pointer;
}
.show{
font-size:1.5rem;
font-weight:bold;
}
</style>
</head>
<body>
<h1>DOM Input month max/min property Demo</h1>
<p>Hi, Do you need leave from your work?</p>
<p>If yes then select your desired one month between April & August:</p>
<input type="month" class="monthInput" min="2019-04" max="2019-08">
<button onclick="showMySelection()" class="btn">Show Result</button>
<div class="show"></div>
<script>
function showMySelection() {
var monthInput = document.querySelector(".monthInput");
var showMsg = document.querySelector(".show");
if(monthInput.value === ''){
showMsg.innerHTML="Please Select!!";
} else {
showMsg.innerHTML=monthInput.value;
}
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

월 입력 필드를 사용하여 임의의 월(4월과 8월 사이) 선택 -

선택 후 "결과 표시를 클릭합니다. ” 버튼을 누르면 선택한 월이 표시됩니다. −
