Search code examples
htmlhtml-input

html input range step as an array of values


I've been playing around with the input type=range for the first time, and ideally I'd like to set the step value to an array of values. I looked over the spec and I see the possibility for a datalist but it seams the data list is only used for highlight values in a range, so to speak, but not setting the values in the range.

So, something like this (ideally without a jQuery plugin, etc.):

<input type="range" min="1" max="100" value="0" step="1,3,5,10,20">

Solution

  • According to the W3C spec, the values for step can be "any" or a positive floating-point number. That's it.

    The step attribute, if specified, must either have a value that is a valid floating-point number that parses to a number that is greater than zero, or must have a value that is an ASCII case-insensitive match for the string "any".