Javascript DOM HTML Input Range form Property

Introduction

Return the id of the form containing the <input type="range"> element:

var x = document.getElementById("myRange").form.id;

Click the button to return the id of the form the slider control belongs to.

View in separate window

<!DOCTYPE html>
<html>
<body>

<form id="myForm">
  <input type="range" id="myRange">
</form>/*from   w w w . ja  v a  2s  .c o  m*/

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

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

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

</body>
</html>

The form property returns a reference to the form containing the slider control.

This property returns a form object on success.

This property is read only.

If the slider control is not in a form, null is returned




PreviousNext

Related