Javascript DOM HTML Output name Property get

Introduction

Get the name of an <output> element:

var x = document.getElementById("myOutput").name;

Click the button to display the name of the output element.

View 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 w w  w  .  java 2s.c o  m
<button type="button" onclick="myFunction()">Test</button>

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

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

</body>
</html>

The name property sets or gets the value of the name attribute of an <output> element.

The name attribute can identify form data after submitting to the server.

The name property returns a String representing the name of the <output> element.




PreviousNext

Related