Slider Widgetversion added: 1.5
Description: Drag a handle to select a numeric value.
Options
animateType: Boolean or String or Number
false
-
Boolean: When set to
true
, the handle will animate with the default duration. -
String: The name of a speed, such as
"fast"
or"slow"
. - Number: The duration of the animation, in milliseconds.
disabledType: Boolean
false
true
.Initialize the slider with the disabled option specified:
$( ".selector" ).slider({ disabled: true }); |
Get or set the disabled option, after initialization:
// getter var disabled = $( ".selector" ).slider( "option" , "disabled" ); // setter $( ".selector" ).slider( "option" , "disabled" , true ); |
orientationType: String
"horizontal"
"horizontal"
, "vertical"
.rangeType: Boolean or String
false
-
Boolean: If set to
true
, the slider will detect if you have two handles and create a stylable range element between these two. -
String: Either
"min"
or"max"
. A min range goes from the slider min to one handle. A max range goes from one handle to the slider max.
stepType: Number
1
valueType: Number
0
Methods
destroy()
- This method does not accept any arguments.
disable()
- This method does not accept any arguments.
enable()
- This method does not accept any arguments.
option( optionName ) Returns: Object
optionName
.-
optionNameType: StringThe name of the option to get.
option() Returns: PlainObject
- This method does not accept any arguments.
option( optionName, value )
optionName
.option( options )
-
optionsType: ObjectA map of option-value pairs to set.
values( index ) Returns: Number
-
indexType: IntegerThe zero-based index of the handle.
values( index, value )
widget() Returns: jQuery
jQuery
object containing the slider.
- This method does not accept any arguments.
Events
change( event, ui )
value
method.slide( event, ui )
ui.value
represents the value that the handle will have as a result of the current movement. Canceling the event will prevent the handle from moving and the handle will continue to have its previous value.start( event, ui )
The jQuery UI Slider plugin makes selected elements into sliders. There are various options such as multiple handles and ranges. The handle can be moved with the mouse or the arrow keys.
The slider widget will create handle elements with the class ui-slider-handle
on initialization. You can specify custom handle elements by creating and appending the elements and adding the ui-slider-handle
class before initialization. It will only create the number of handles needed to match the length of value
/values
. For example, if you specify values: [ 1, 5, 18 ]
and create one custom handle, the plugin will create the other two.
Additional Notes:
- This widget requires some functional CSS, otherwise it won't work. If you build a custom theme, use the widget's specific CSS file as a starting point.
Example:
A simple jQuery UI Slider.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <!doctype html> < html lang = "en" > < head > < meta charset = "utf-8" > < title >slider demo</ title > < style >#slider { margin: 10px; } </ style > </ head > < body > < div id = "slider" ></ div > < script > $( "#slider" ).slider(); </ script > </ body > </ html > |