Output htmlFor Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Output

Description

The htmlFor property returns the for attribute of an <output> element.

This property is read-only.

Return Value

input element id

The following code shows how to get the relationship between the result of the calculation, and the elements used in the calculation:

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  w  w  w .  ja v  a 2s.c o m*/

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

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

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

</body>
</html>

Related Tutorials