Get Output Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Output

Introduction

The Output object represents an HTML <output> element.

You can access an <output> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!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>/*from ww w .j a  va2 s .c  o  m*/

<button type="button" onclick="myFunction()">display the name of the output element</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myOutput").name;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials