Javascript DOM HTML Input Month stepUp() Method

Introduction

Increment the value of a month field by 3 months:

Click the button to increment the value of the month field by 3 months.

The stepUp() method is not supported by Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body>

Month and year: <input type="month" id="myMonth" value="1997-11">
<button onclick="myFunction()">Test</button>
<script>
function myFunction() {//from w w w  . j a  v  a2s. c o m
  document.getElementById("myMonth").stepUp(3);
}
</script>

</body>
</html>

The stepDown() method increments the value of the month field by a specified number.

This method will only have an affect on Months.

Parameter Description
numberRequired. Specifies the amount of months the month field should increase.

If omitted, the months are incremented by "1"




PreviousNext

Related