Slider

Home

Slider

To add a slider widget to your page, use a standard input with the type="range" attribute. The input's value is used to configure the starting position of the handle and the value populated in the text input. Specify min and max attribute values to set the slider's range. The framework will parse these attributes to configure the slider widget.

As you drag the slider's handle, the framework will update the native input's value (and vice-versa) so they are always in sync; this ensures that the value is submitted with the form.

Set the for attribute of the label to match the ID of the input so they are semantically associated and wrap them in a div with the data-role="fieldcontain" attribute to group them.


<div data-role="fieldcontain">
   <label for="slider">Input slider:</label>
   <input type="range" name="slider" id="slider" value="25" min="0" max="100"  />
</div>

The default slider is displayed like this:

Sliders also respond to key commands. Right Arrow, Up Arrow, and Page Up keys increase the value; Left Arrow, Down Arrow, and Page Down keys decrease it. To move the slider to its minimum or maximum value, use the Home or End key, respectively.

Calling the slider plugin

This plugin will auto initialize on any page that contains a text input with the type="range" attribute. However, if needed you can directly call the slider plugin on any selector, just like any jQuery plugin:


$('input').slider();