Javascript DOM HTML Input Number stepDown() Method

Introduction

Decrement the value of a number field by 5:

document.getElementById("myNumber").stepDown(5);

Click the button to decrement the value of the number field by 5.

View in separate window

<!DOCTYPE html>
<html>
<body>

Number: <input type="number" id="myNumber">
<button onclick="myFunction()">Test</button>
<script>
function myFunction() {//from   www.  j av  a2s  .com
  document.getElementById("myNumber").stepDown(5);
}
</script>

</body>
</html>

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

Parameter Description
numberRequired. Set the amount the value of the number field should decrease.

If omitted, the numbers are decremented by "1"




PreviousNext

Related