Getting Started With jQuery UI
Getting Started With jQuery UI
Written by Ian Elliot   
Monday, 28 January 2013
Article Index
Getting Started With jQuery UI
Doing more with the Slider


Slider Settings

This gives you the basic operation of a slider - what else can you change?

You can set the max and min values that the slider will return via the max and min properties. You can also set the step size, i.e the amount the slider moves each time using the step property. Finally you can set the orientation using the orientation property.

So, for example, to set up a vertical slider working between 1 and -1 with a step size of 0.1 and a display of the value as the user moves the slider.

The HTML can be as simple as:

<div id="mySliderDiv">
<div id="myText">

 The code is:

       max:1, min:-1,
       slide: function(event, ui) {

If you run this then you will see a vertical slider with the current value changing below it as the user moves the slider.



Range Slider

As well as the standard slider you can also implement a range slider - one that has two sliders, allowing the user to setup a max and min for a range.

All you have to do is set the range property to true and then set values to an array giving the max and min properties of the two sliders.

For example


creates a slider with two slides ranging between 0 and 100 and one initially set to 25 and the other to 75. You can also have a slider with a fixed max or min by setting the range to "max" or "min"

You can get the values for the sliders using the  values() or value(index) methods. For example

var values=$("#mySliderDiv").slider("values);

returns an array of values.

Changing the Style

You might not be happy with the default style of the slider. To change it all you have is create a new style sheet that applies styles to the standard classes set up by the constructor.

You can find out the classes that are used by examining the slider element using Firebug say:

<div id="mySliderDiv"
 <a class="ui-slider-handle
           ui-corner-all" href="#">

From this you can see that to customize the slider handle you need to modify the ui-slider-handle, the ui-state-default or the  ui-corner-all class. The problem is always finding out which one to change.

You can create complete themed sets of styles using the ThemeRoller where you will also find predefined styles you can use.

If you want to do something radical to the slider handle then the best approach is to just jQuery to remove the assigned styles and apply your own.


JavaScript Data Structures - Array Object

When JavaScript was first introduced to the world it didn't have a dedicated Array data structure - it simply didn't need one, but it got one nevertheless!

Here we look at the Array object, which is  [ ... ]

jQuery 3 - Forms

Forms are a special part of the HTML UI because they provided a way to get data back to the server. You can get data back to the server in other ways, namely Ajax but Forms are still a good way to wor [ ... ]

Other Articles

Last Updated ( Tuesday, 25 August 2015 )

Copyright © 2017 All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.