HTML DOM 입력 월 stepUp() 메소드는 입력 월 필드의 값을 지정된 값만큼 증가(증가)시킵니다.
구문
다음은 구문입니다 -
object.stepUp(number)
여기에서 숫자인 경우 매개변수가 생략되면 값이 1씩 증가합니다.
예시
월 입력 stepUp() 메소드의 예를 보자 -
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM stepUp()/stepDown() Demo</title>
<style>
body{
text-align:center;
background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%)
center/cover no-repeat;
height:100vh;
color:#fff;
}
p{
font-size:1.5rem;
}
input{
width:40%;
}
button{
background-color:#db133a;
color:#fff;
padding:8px;
border:none;
width:120px;
margin:1rem;
border-radius:50px;
outline:none;
cursor:pointer;
}
</style>
</head>
<body>
<h1>stepUp()/stepDown() Method Demo</h1>
<p>Hi! Select your month of birth</p>
<input type="month">
<br>
<button onclick="incValue()">StepUp Value</button>
<button onclick="decValue()">StepDown Value</button>
<script>
function incValue() {
document.querySelector("input").stepUp();
}
function decValue() {
document.querySelector("input").stepDown();
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

"StepUp 값" 또는 "StepDown 값을 클릭합니다. ” 버튼을 눌러 입력 월 필드의 값을 증가 또는 감소시킵니다.

