<input type="range" id="b" name="b" value="50" /> +
<input type="number" id="a" name="a" value="10" /> =
<output id="result" for="a b">60</output>`<output>` HTML output element / notebook
`<output>` HTML output element
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const a = document.getElementById("a");
const b = document.getElementById("b");
const result = document.getElementById("result");
function updateResult() {
const aValue = a.valueAsNumber;
const bValue = b.valueAsNumber;
result.value = aValue + bValue;
}
a.addEventListener("input", updateResult);
b.addEventListener("input", updateResult);
updateResult();