Javascript DOM HTML Input Range Object get

Introduction

The Input Range object represents an HTML <input> element with type="range".

We can access an <input> element with type="range" via document.getElementById():

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

Click the button to get the value of the slider control.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="range" id="myRange" value="90">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//from  w w  w  .ja v  a 2  s .co  m
  var x = document.getElementById("myRange").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

You can also access <input type="range"> by searching through the elements collection of a form.




PreviousNext

Related