Javascript DOM HTML Input Range step Property set

Introduction

Change the value of the step attribute:

document.getElementById("myRange").step = "25";

Click the button to change the value of the step attribute of the slider control.

View in separate window

<!DOCTYPE html>
<html>
<body>

Points: <input type="range" id="myRange" step="5">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//from w  w  w  . ja  v a2  s. c om
  var x = document.getElementById("myRange").step = "25";
  document.getElementById("demo").innerHTML = "The value of the step attribute was changed from '5' to '25'.";
}
</script>

</body>
</html>

The step property sets or gets the step attribute of a slider control.

The step attribute sets the size of each movement of the slider control.

The step property accepts and returns a number type value.




PreviousNext

Related