DOM Methods

HTMLInputElement.stepUp()

Build a form with the HTML form generator

Increases a supported numeric or date/time input by a number of allowed steps. The step size and bounds depend on the input type and attributes. Unsupported types or step=any can throw InvalidStateError. This is not arbitrary addition to a text field. Example result: 6.

Formal Syntax & Structure

html syntaxhtml
element.stepUp(n)

Parameters & Attributes

NameTypeDescription
nnumberOptional integer number of steps, default 1.

Return Value

undefined

No return value.

Working Example

Example Snippethtml
<input id="demo" type="number" min="0" max="10" step="2" value="2"><p>  Result:  <output id="result"></output></p><script>  const e = document.getElementById('demo');  const result = value => { document.getElementById("result").textContent = String(value); };  e.stepUp(2); result(e.valueAsNumber);</script>
HTML Reference