jQuery only range slider

Overview

ion.rangeSlider

Ion.RangeSlider. Is an easy, flexible and responsive range slider with tons of options.


Description

  • Ion.RangeSlider — cool, comfortable, responsive and easily customizable range slider
  • Supports events and public methods, has flexible settings, can be completely altered with CSS
  • Cross-browser: Google Chrome, Mozilla Firefox 3.6+, Opera 12+, Safari 5+, Internet Explorer 8+
  • Ion.RangeSlider supports touch-devices (iPhone, iPad, Nexus, etc.).
  • Ion.RangeSlider freely distributed under terms of MIT licence.
  • With this plugin you will be able to build beautiful range sliders, like this:

ion.rangeSlider

Key features

  • Skin support. (6 skins included)
  • Any number of sliders at one page without conflicts and big performance problems
  • Two slider types single (1 slider) and double (2 sliders)
  • Support of negative and fractional values
  • Ability to set custom step and snap grid to step
  • Support of custom values diapason
  • Customisable grid of values
  • Ability to disable UI elements (min and max, current value, grid)
  • Postfixes and prefixes for your numbers ($20, 20 € etc.)
  • Additional postfix for maximum value (eg. $0 — $100+)
  • Ability to prettify large numbers (eg. 10000000 -> 10 000 000 or 10.000.000)
  • Slider writes its value right into input value field. This makes it easy to use in any html form
  • Any slider value can be set through input data-attribute (eg. data-min="10")
  • Slider supports disable param. You can set it true to make slider inactive
  • Slider supports external methods (update, reset and remove) to control it after creation
  • For advanced users slider has callbacks (onStart, onChange, onFinish, onUpdate). Slider pastes all its params to callback first argument as object
  • Slider supports date and time

Demos

Dependencies

Usage

Add the following libraries to the page:

  • jQuery
  • ion.rangeSlider.min.js

Add the following stylesheets to the page:

  • ion.rangeSlider.min.css

CDN

Use CDNjs or JSdelivr to get latest version of plugin and jQuery.

<!--Plugin CSS file with desired skin-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.1/css/ion.rangeSlider.min.css"/>

<!--jQuery-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<!--Plugin JavaScript file-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.1/js/ion.rangeSlider.min.js"></script>   

Install with NPM

Use NPM to download latest version of a plugin and install it directly in to your project.

  • npm install ion-rangeslider

Install with Bower

Use Bower to download latest version of a plugin and install it directly in to your project.

  • bower install ion-rangeslider

Install with Yarn

Use Yarn to download latest version of a plugin and install it directly in to your project.

  • yarn add ion-rangeslider

Initialisation

The slider overrides a native text input element.

<input type="text" id="example_id" name="example_name" value="" />

To initialise the slider, call ionRangeSlider on the element:

$("#example_id").ionRangeSlider();

Experiments playground

Here you can find bunch of advanced JSFIDDLE demos with different, non-standard use cases:

Settings

Option Data-Attr Defaults Type Description
skin data-skin flat string Choose UI skin to use (flat, big, modern, round, sharp, square)
type data-type single string Choose slider type, could be single - for one handle, or double for two handles
min data-min 10 number Set slider minimum value
max data-max 100 number Set slider maximum value
from data-from min number Set start position for left handle (or for single handle)
to data-to max number Set start position for right handle
step data-step 1 number Set sliders step. Always > 0. Could be fractional
min_interval data-min-interval - number Set minimum diapason between sliders. Only for double type
max_interval data-max-interval - number Set minimum maximum between sliders. Only for double type
drag_interval data-drag-interval false boolean Allow user to drag whole range. Only for double type
values data-values [] array Set up your own array of possible slider values. They could be numbers or strings. If the values array is set up, min, max and step param, can no longer be changed
from_fixed data-from-fixed false boolean Fix position of left (or single) handle
from_min data-from-min min number Set minimum limit for left (or single) handle
from_max data-from-max max number Set maximum limit for left (or single) handle
from_shadow data-from-shadow false boolean Highlight the limits for left handle
to_fixed data-to-fixed false boolean Fix position of right handle
to_min data-to-min min number Set minimum limit for right handle
to_max data-to-max max number Set maximum limit for right handle
to_shadow data-to-shadow false boolean Highlight the right handle
prettify_enabled data-prettify-enabled true boolean Improve readability of long numbers: 10000000 → 10 000 000
prettify_separator data-prettify-separator string Set up your own separator for long numbers: 10000000 → 10,000,000 etc.
prettify - null function Set up your own prettify function. Can be anything. For example, you can set up unix time as slider values and than transform them to cool looking dates
force_edges data-force-edges false boolean Sliders handles and tooltips will be always inside it's container
keyboard data-keyboard true boolean Activates keyboard controls. Move left: ←, ↓, A, S. Move right: →, ↑, W, D.
grid data-grid true boolean Enables grid of values above the slider
grid_margin data-grid-margin true boolean Set left and right grid gaps
grid_num data-grid-num 4 number Number of grid units
grid_snap data-grid-snap false boolean Snap grid to sliders step (step param). If activated, grid_num will not be used. Max steps = 50
hide_min_max data-hide-min-max false boolean Hides min and max labels
hide_from_to data-hide-from-to false boolean Hides from and to labels
prefix data-prefix `` string Set prefix for values. Will be set up right before the number: **$**100
postfix data-postfix `` string Set postfix for values. Will be set up right after the number: 100k
max_postfix data-max-postfix `` string Special postfix, used only for maximum value. Will be showed after handle will reach maximum right position. For example 0 — 100+
decorate_both data-decorate-both true boolean Used for double type and only if prefix or postfix was set up. Determine how to decorate close values. For example: $10k — $100k or $10 — 100k
values_separator data-decorate-both - string Set your own separator for close values. Used for double type. Default: 10 — 100. Or you may set: 10 to 100, 10 + 100, 10 → 100 etc.
input_values_separator data-input-values-separator ; string Separator for double values in input value property. <input value="25;42">
disable data-disable false boolean Locks slider and makes it inactive. Input is disabled too. Invisible to forms
block data-blokc false boolean Locks slider and makes it inactive. Input is NOT disabled. Can be send with forms
extra_classes data-extra-classes string Traverse extra CSS-classes to sliders container
scope - null object Scope for callbacks. Pass any object
onStart - null function Callback. Is called on slider start. Gets all slider data as a 1st attribute
onChange - null function Callback. IS called on each values change. Gets all slider data as a 1st attribute
onFinish - null function Callback. Is called when user releases handle. Gets all slider data as a 1st attribute
onUpdate - null function Callback. Is called when slider is modified by external methods update or reset

Description of data passed to callbacks (onChange and etc.)

Result is object type and passed to callback as first argument:

Obj: {
    "input": object,            // jQuery-link to input
    "slider": object,           // jQuery-link to sliders container
    "min": 1000,                // MIN value
    "max": 100000,              // MAX values
    "from": 10000,              // FROM value
    "from_percent": 10,         // FROM value in percents
    "from_value": 0,            // FROM index in values array (if used)
    "to": 90000,                // TO value
    "to_percent": 90,           // TO value in percents
    "to_value": 0,              // TO index in values array (if used)
    "min_pretty": "1 000",      // MIN prettified (if used)
    "max_pretty": "100 000",    // MAX prettified (if used)
    "from_pretty": "10 000",    // FROM prettified (if used)
    "to_pretty": "90 000"       // TO prettified (if used)
}

Creating slider (all params)

An example of a customised slider:

$("#example").ionRangeSlider({
    skin: "big",
    min: 0,
    max: 10000,
    from: 1000,
    to: 9000,
    type: 'double',
    prefix: "$",
    grid: true,
    grid_num: 10
});

You can also initialise slider with data-* attributes of input tag:

data-min="0"
data-max="10000"
data-from="1000"
data-to="9000"
data-type="double"
data-prefix="$"
data-grid="true"
data-grid-num="10"

Public methods

To use public methods, at first you must save slider instance to variable:

// Launch plugin
$("#range").ionRangeSlider({
    type: "double",
    min: 0,
    max: 1000,
    from: 200,
    to: 500,
    grid: true
});

// Saving it's instance to var
var slider = $("#range").data("ionRangeSlider");

// Fire public method
slider.reset();

There are 3 public methods:

// UPDATE - updates slider to any new values
slider.update({
    from: 300,
    to: 400
});

// RESET - reset slider to it's first values
slider.reset();

// DESTROY - destroys slider and restores original input field
slider.destroy();

One more look on demos

All plugins options are covered in demos.

Update history


Support Ion-series plugins development:

Comments
  • Slider maximum is rounded down on certain cases

    Slider maximum is rounded down on certain cases

    Hi,

    The issue is when the max value is say 4.71 and step value is 0.10, then the slider maximum is rounded down to 4.70 and the slider pointer could not be moved further to reach the maximum of 4.71.

    i.e the maximum value is rounded down to x.00 for all the slider maximum values ranging from x.01 to x.04 and with the example step value of 0.10.

    But the maximum is set correctly for the values ranging from x.05 to x.09. The slider pointer can move up till the maximum without any rounding.

    For more detail please refer and compare case 1 and case 3 in the demo http://jsfiddle.net/Megala/d8gf0k2t/2/

    Could you please check this?

    If anything is not clear, please let me know.

    Thanks, Megala

    [bug] low priority 
    opened by megals 30
  • Update a slider with a custom value (not in the values set) in a slider with fixed values

    Update a slider with a custom value (not in the values set) in a slider with fixed values

    Hi there:

    I have a rangeslider with custom values set ([1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000, 1500, 2000, 2500, 3000, 4000, 5000])

    User can play with this values, but I have an external input when the value of the slider is updated. But I would like this input to be changed by the user and set any number, any custom number, for example: 77.

    I have noticed that if I update the number of a rangeslider with fixed values, the "ball" goes to the index number of that numbers set.

    How can I move the ball to the exact point when the ball should be if instead a set of values it would be a range from 1 to 5000 (in my case) ?

    Difficult, uh ? ;-)

    Discussion 
    opened by klikin 22
  • No Answer Option

    No Answer Option

    Hi there, I want to add a "no answer option" by a button added under the slider.

    On click the slider shall be set on zero.

    is this possible?

    Thanks for answer, Mart

    Help wanted 
    opened by MartH78 14
  • Add Reverse Option

    Add Reverse Option

    Fixes #234

    Using the prettify reverse method won't do the trick when working with from and to values.

    It will require extra work to reverse inputs too, for example: Fixing to value should fix the upper bound and release the lower bound.

    I approached this by reversing the UI only, which also makes it usable in a Right-to-Left layout with ease.

    Not sure if this going to be merged or not! so I only reversed the HTML5 skin, other skins reversal should be straight forward!

    TODO:

    • Reverse the remaining skins.
    • Test all cases, I might have missed something!

    Thanks

    Feature request High priority 
    opened by MohammadYounes 14
  • update when custom values

    update when custom values

    Great component. I am working with it for a few hours and is great. I had only see one issue: when you use custom values despite numbers, the update method doesnt work fine. Could anybody check it?

    Discussion 
    opened by Nickholas 13
  • Is it possible to move the slider using the from-to labels ?

    Is it possible to move the slider using the from-to labels ?

    I actually want my slider to slide using the from and to label. That is when someone click and drag the from or to label, the slider should move.

    I tried to see the doc (http://ionden.com/a/plugins/ion.rangeSlider/en.html) , but found nothing.

    what should I do so that my slider move using those label?

    https://cloud.githubusercontent.com/assets/2056756/7346000/ccfab81e-ecf7-11e4-9658-c50cf248656b.png

    Feature request 
    opened by govindpatel 12
  • Rangeslider only works in Firefox

    Rangeslider only works in Firefox

    Hi,

    i inclded the slider, use it with custom values and the slider seems to load okay but in Chrome and IE i can not drag the handles. Any idea what i'm doing wrong?

        var $cabins = $("#cabin-slider");
    
        $cabins.ionRangeSlider({
            type: "double",
            values: ["2","3","4","5","5+"],
        });
    
        $cabins.on("change", function () {
            var $this = $(this),
                value = $this.prop("value").split(";");
    
            $('#cabins').val(value[0] + "-" + value[1]);
        });
    
    Discussion 
    opened by prentice87 12
  • Performance issue on update FF and IE

    Performance issue on update FF and IE

    I am working on CSS generator that is using about 40+ sliders as options. On load the performance is ok , but when I need to update there is a noticeable lag on IE and FF. Chrome , Safari, Opera look ok .

    Here is fiddle

    http://jsfiddle.net/p9fsyx84/

    note that on button click I must update all form inputs. With this lag , combined with CSS that needs to be applied to the page , I am looking at the 3-5 sec lag until all sliders have finished.

    Discussion 
    opened by danyj 11
  • Не могу задестроить сущность

    Не могу задестроить сущность

    var slider = $range.data("ionRangeSlider"); Возвращает undefined соответственно задестроить нечего.

    Делаю как в мануале 1 в 1. Нужна помощь.

    Discussion 
    opened by ghost 11
  • Slider position resets to minimum on single slider for certain combination of from value and step

    Slider position resets to minimum on single slider for certain combination of from value and step

    Hi, I'm having issue detailed below with the slider.

    Slider position resets to minimum on a slider type single for certain values. This happens specifically when we call the slider update after initialising the slider with the values mentioned.

    Example values: Slider max and from as 4.75 and step value 0.10 Slider max and from as 2.28 and step value 0.20

    The slider works fine for the values given below Slider max and from as 4.71 and step value 0.10 Slider max and from as 2.24 and step value 0.20

    If you would like to see the slider behaviour for all these examples, please check http://jsfiddle.net/Megala/d8gf0k2t/

    Your response to this will be much appreciated.

    Thanks

    [bug] normal priority 
    opened by megals 11
  • the grid does not work correctly in bootstrap model

    the grid does not work correctly in bootstrap model

    I using rangeSlider in bootstap's model: http://getbootstrap.com/javascript/#modals

    It seems the grid layout position is wrong:

    n2 y4 673 l9b9h 2_tuo

    My code is :

                min: 10,
                max: 50,
                from: 5,
                to: 25,
                type: 'double',
                step: 1,
                postfix: "°",
                prettify: false,
                hasGrid: true
            });
    

    which works fine in the index page.

    Any way to fix it??

    Discussion 
    opened by mainlove 11
  • Installed via NPM: Uncaught TypeError: $(...).ionRangeSlider is not a function

    Installed via NPM: Uncaught TypeError: $(...).ionRangeSlider is not a function

    I've got a Laravel project. I've just installed jQuery and ion.rangeSlider through npm.

    "ion-rangeslider": "^2.3.1",
    "jquery": "^3.6.0"
    

    JQuery works as expected in the project. Trying to do the most basic example of a slider (for example below), I get an error:

    <input name="MyCoolField" class="form-control" type="text" />
    
    <script>
    $(function() {
        $("[name=MyCoolField]").ionRangeSlider({
            type: "double",
            min: 0,
            max: 1000,
            from: 200,
            to: 500,
            grid: true
        });
    });
    </script>
    
    

    The Error Is:

    jquery.js?8262:4059 Uncaught TypeError: $(...).ionRangeSlider is not a function
        at HTMLDocument.eval (_filter-form.js?a5ef:22:32)
        at mightThrow (jquery.js?8262:3766:1)
        at process (jquery.js?8262:3834:1)
    
    Help wanted 
    opened by JamesMcFall 3
  • Allow typing input-values

    Allow typing input-values

    Sometimes the automatic grid-steps are too wide apart, so that the graphic input-selection is not sufficient. It would be a nice enhancement to allow typing the input-numbers, e.g. activate input-field by clicking on the input numbers like it is available in Spotfire.

    opened by hillenbc 2
  • Adding new sliders via JS

    Adding new sliders via JS

    Hi,

    I'm attempting to add new sliders via JS, but initializing by class messes up the whole page, while initializing by id disables the previously created instances.

    I'm sure its something easy, i just can't figure it out on my own :(

    Here is what i'm talking about: https://jsfiddle.net/insideru/6y2kw57m/3/

    Help wanted 
    opened by insideru 0
  • Display issue when parent element is using display: inline-flex or display: flex

    Display issue when parent element is using display: inline-flex or display: flex

    Hi,

    There is an issue when using range slider when a container has display: inline-flex or display: flex CSS rule.

    When this happens range slider's width looks like it would be set to 0. Elements are displayed but are squeezed.

    I used exisiting example from contributing guidelines here: https://jsfiddle.net/IonDen/b79q0vnm and added display: inline-flex to show this behavior: https://jsfiddle.net/16jvpk8d/

    opened by tmszb 2
Releases(2.3.1)
Owner
Denis Ineshin
JavaScript developer
Denis Ineshin
noUiSlider is a lightweight JavaScript range slider library with full multi-touch support. It fits wonderfully in responsive designs and has no dependencies.

noUiSlider noUiSlider is a lightweight JavaScript range slider. No dependencies All modern browsers and IE > 9 are supported Fully responsive Multi-to

Léon Gersen 5.4k Dec 28, 2022
🎚 HTML5 input range slider element polyfill

rangeslider.js Simple, small and fast jQuery polyfill for the HTML5 <input type="range"> slider element. Check out the examples. Touchscreen friendly

André Ruffert 2.2k Jan 8, 2023
Swiffy-slider - Super fast carousel and slider with touch for optimized websites running in modern browsers.

Swiffy Slider Super fast lightweight carousel and slider with touch for optimized websites running in modern browsers. Explore Swiffy Slider docs » Se

Dynamicweb Software A/S 149 Dec 28, 2022
An awesome, fully responsive jQuery slider plugin

FlexSlider 2.7.2 http://www.woocommerce.com/flexslider/ - Copyright (c) 2015 WooThemes Releases The master branch of this repository is always the lat

WooCommerce 4.9k Jan 3, 2023
:snowboarder: A responsive slider jQuery plugin with CSS animations

A responsive slider jQuery plugin with CSS animations Animations from animate.css Online demo Visit plugin website. Appszoom for developers also uses

Joan Claret 58 Dec 12, 2022
A jQuery plugin for a slider with adaptive colored figcaption and navigation.

Adaptive Slider jQuery Plugin A jQuery plugin for a slider with adaptive colored figcaption and navigation. This plugin will take a list of figure ele

null 53 Jan 3, 2023
Most modern mobile touch slider with hardware accelerated transitions

Get Started | Documentation | Demos Swiper Swiper - is the free and most modern mobile touch slider with hardware accelerated transitions and amazing

Vladimir Kharlampidi 33.7k Jan 9, 2023
A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more

Glide.js is a dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more What can co

null 6.7k Jan 7, 2023
OlumSlider is a lightweight and flexible slider, written via vanilla js

olum-slider OlumSlider is a lightweight and flexible slider, written via vanilla js Documentation CDN <!DOCTYPE html> <html lang="en"> <head> <t

Olumjs 0 Oct 8, 2021
Extended carousel based on Bootstrap 5 using only vanilla js.

Description Extended Slider based on Bootstrap 5 using only carousel component and vanilla js. Requirements: Bootstrap 5 Installation npm i -D extende

Carlos Pozo 7 Jul 26, 2022
A browser only tool for converting npm package to ES module.

es-modularize A browser only tool for converting npm package to ES module. This library allows the following code to work correctly in browser thanks

null 14 Dec 13, 2022
Vegas is a jQuery/Zepto plugin to add beautiful backgrounds and Slideshows to DOM elements.

Vegas – Backgrounds and Slideshows Vegas is a jQuery/Zepto plugin to add beautiful backgrounds and Slideshows to DOM elements. Important note: Vegas 2

Jay Salvat 1.8k Jan 7, 2023
jQuery only range slider

Ion.RangeSlider. Is an easy, flexible and responsive range slider with tons of options. Version: 2.3.1 | Version 3.x is under development now Project

Denis Ineshin 2.5k Dec 25, 2022
A jquery UI range selection slider that supports dates

jQRangeSlider, jQDateRangeSlider & jQEditRangeSlider A javascript slider selector that supports dates and touch devices Home page Documentation Suppor

Guillaume Gautreau 676 Sep 24, 2022
A lightweight (~2kB) library to create range sliders that can capture a value or a range of values with one or two drag handles

range-slider-input A lightweight (~2kB) library to create range sliders that can capture a value or a range of values with one or two drag handles. Ex

Utkarsh Verma 42 Dec 24, 2022
Generate release notes from git commit history either commit range or tag range.

Would you like to support me? Release Notes Generate release notes from git commit history either commit range or tag range. App Store Template Change

Numan 6 Oct 8, 2022
Nivo Slider - The Most Awesome jQuery Image Slider

Maintainer's Wanted! - Ineterested in contributing regularly to Nivo Slider development? Get in touch Nivo Slider The Nivo Slider is world renowned as

Verti Studio 1.2k Dec 24, 2022
Accordion Slider is a jQuery plugin that combines the functionality of a slider with that of an accordion.

Accordion Slider - jQuery slider plugin A responsive and touch-enabled jQuery accordion slider plugin that combines the functionality of a slider with

null 0 Dec 29, 2022
noUiSlider is a lightweight JavaScript range slider library with full multi-touch support. It fits wonderfully in responsive designs and has no dependencies.

noUiSlider noUiSlider is a lightweight JavaScript range slider. No dependencies All modern browsers and IE > 9 are supported Fully responsive Multi-to

Léon Gersen 5.4k Dec 28, 2022
🎚 HTML5 input range slider element polyfill

rangeslider.js Simple, small and fast jQuery polyfill for the HTML5 <input type="range"> slider element. Check out the examples. Touchscreen friendly

André Ruffert 2.2k Jan 8, 2023