Javascript DOM HTML Input Range value Property get

Introduction

Get the value of a slider control:

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

Click the button to display the value attribute of the slider control.

View in separate window

<!DOCTYPE html>
<html>
<body>

Points: <input type="range" id="myRange" value="20">

<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {/*from   www  .j av a 2  s . c om*/
  var x = document.getElementById("myRange").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related