Build jQuery UI Slider - Range slider in JavaScript
Description
The following code shows how to build jQuery UI Slider - Range slider.
Example
<!-- Revised from demo code on http://jqueryui.com/ -->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Slider - Range slider</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<!-- www . j av a2s . com-->
<script>
$(function() {
$( "#slider-range" ).slider({
range: true,
min: 0,
max: 500,
values: [ 75, 300 ],
slide: function( event, ui ) {
$( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
}
});
$( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
" - $" + $( "#slider-range" ).slider( "values", 1 ) );
});
</script>
</head>
<body>
<p>
<label for="amount">Price range:</label>
<input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />
</p>
<div id="slider-range"></div>
<div class="demo-description">
<p>Set the <code>range</code> option to true to capture a range of values with two drag handles. The space between the handles is filled with a different background color to indicate those values are selected.</p>
</div>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Slider
Build jQuery UI Slider - Colorpicker in Jav...
Build jQuery UI Slider - Default functional...
Build jQuery UI Slider - Multiple sliders i...
Build jQuery UI Slider - Range with fixed m...
Build jQuery UI Slider - Slider bound to se...
Build jQuery UI Slider - Slider scrollbar i...
Build jQuery UI Slider - Snap to increments...
Build jQuery UI Slider - Vertical range sli...
Build jQuery UI Slider - Vertical slider in...
Create a Slide in/out dialog in JavaScript
Handle Slider events: change, slide, start,...
Set step value for slider in JavaScript
Set the max value for slider in JavaScript
Share Three sliders for event handler in Ja...
Build jQuery UI Slider - Colorpicker in Jav...
Build jQuery UI Slider - Default functional...
Build jQuery UI Slider - Multiple sliders i...
Build jQuery UI Slider - Range slider in Ja...
Build jQuery UI Slider - Range with fixed m...Build jQuery UI Slider - Range with fixed m...
Build jQuery UI Slider - Slider bound to se...
Build jQuery UI Slider - Slider scrollbar i...
Build jQuery UI Slider - Snap to increments...
Build jQuery UI Slider - Vertical range sli...
Build jQuery UI Slider - Vertical slider in...
Create a Slide in/out dialog in JavaScript
Handle Slider events: change, slide, start,...
Set step value for slider in JavaScript
Set the max value for slider in JavaScript
Share Three sliders for event handler in Ja...