Set the result of a calculation:
document.getElementById("myOutput").value = "150";
Click the button to set the result of the calculation above to "150".
<!DOCTYPE html> <html> <body> <form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0 <input type="range" id="a" value="50">100 +<input type="number" id="b" value="50"> =<output id="myOutput" name="x" for="a b"></output> </form>/*www . ja v a2s . c om*/ <button type="button" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myOutput").value = "150"; } </script> </body> </html>
The value property sets or gets the value of the <output> element.
The value represents the result of a calculation.
The value property accepts and returns a String type value.