Find out which HTML element the Output object represents:
var x = document.getElementById("myOutput").type;
Click the button to find out which HTML element the Output object represents.
<!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 ww. ja va 2s .c om*/ <button type="button" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myOutput").type; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The type property returns which type of element the Output object represents.
For an Output object, this property will always return "output".