Output name Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Output

Description

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

Set the name property with the following Values

Value Description
name Sets the name of the <output> element

Return Value

A String, representing the name of the <output> element

The following code shows how to get the name of an <output> element:

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  av a2 s.c om*/

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

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

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

</body>
</html>

Related Tutorials