Javascript examples for DOM HTML Element:Output
The value property sets or gets the value of the <output> element, which represents the result of a calculation.
Set the value property with the following Values
Value | Description |
---|---|
result | Sets the result of the calculation |
A String, representing the result of the calculation
The following code shows how to Set the result of a calculation:
<!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>/* w w w. ja va 2 s. c o m*/ <button type="button" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myOutput").value; document.getElementById("demo").innerHTML = x; } </script> </body> </html>