Javascript DOM HTML Output name Property set

Introduction

Change the name of an <output> element:

document.getElementById("myOutput").name = "newOutputName";

Click the button to change 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. j a  va 2s  .c o m

<button type="button" onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
  document.getElementById("myOutput").name = "newOutputName";
  document.getElementById("demo").innerHTML = "The name of the output element was changed.";
}
</script>

</body>
</html>



PreviousNext

Related