JQuery UI Range Slider Tutorial Example

Admin   Jquery   527  2021-03-13 16:50:04

Hi Guys,

In this example,I will learn you how to use range slider in jquery ui.you can easy use range silder in jquery ui.

jQuery UI slider is used to obtain a numeric value within a certain range. The main advantage of slider over text input is that it becomes impossible for the users to enter an invalid value.

Example :

 

<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>jQuery UI Slider - Range slider Example</title>

<link href="https://fonts.googleapis.com/css2?family=K2D:[email protected]&family=Pathway+Gothic+One&display=swap" target="_blank" rel="nofollow" rel="stylesheet">

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" target="_blank" rel="nofollow" >

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>

<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<style type="text/css">

body{

font-family: 'K2D', sans-serif;

}

.content{

width:350px;

margin:40px auto;

}

h2{

text-align: center;

}

</style>

</head>

<body>

<h2>JQuery UI Range Slider Tutorial Example - </h2>

<div class="content">

<p>

<label for="amount">Price range:</label>

<input type="text" id="amount" readonly style="border:0; color:#f6931f; font-weight:bold;">

</p>

<div id="slider-range"></div>

</div>

</body>

<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>

</html>

It will help you...