Jump to content


  • Posts

  • Joined

  • Last visited

Roland's Achievements


Newbie (1/7)



  1. Hi, I have a suggestion for improving the Input Range step Property, here: https://www.w3schools.com/jsref/prop_range_step.asp I found that the Try It Yourself code lacks context as it doesn't show a value, min or max attribute in the input element so the step attribute doesn't have much meaning. https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_range_step Here is my suggestion for improving the code. You may want to remove the Try it button seeing as the innerHTML is being updated each time the slider changes: Thanks, Roland <!DOCTYPE html> <html> <body> Points: 1 <input type="range" id="myRange" value="5" step="1" min="1" max="10"> 10 <p>Click the button to display the value and the step attribute of the slider control.</p> <button onclick="myFunction()">Try it</button> <p><strong>Note:</strong> input elements with type="range" are not supported in IE 9 and earlier versions.</p> <p id="demo"></p> <script> function myFunction() { var step = document.getElementById("myRange").step; var value = document.getElementById("myRange").value; document.getElementById("demo").innerHTML = 'step:' + step + ', value:' + value; } document.getElementById("myRange").addEventListener('input', function(e) { myFunction(); }); myFunction(); </script> </body> </html>
  • Create New...