Web APIs

HTMLInputElement.value

Try the free JavaScript compiler

Read or set the current string value. Number inputs still expose a string through this property; use valueAsNumber for numeric conversion. Example console output: string 12.

Formal Syntax & Structure

javascript syntaxjavascript
input.value

Return Value

string

Current control value.

Working Example

Example Snippetjavascript
const i=document.createElement("input"); i.type="number"; i.value="12"; console.log(typeof i.value,i.value);
JavaScript Reference