I've been looking for a lightweight, dependency free dual slider for some time (it seemed crazy to import jQuery just for this) and there don't seem to be many out there. I ended up modifying @Wildhoney's code a bit and really like it.

function getVals(){
  // Get slider values
  var parent = this.parentNode;
  var slides = parent.getElementsByTagName("input");
    var slide1 = parseFloat( slides[0].value );
    var slide2 = parseFloat( slides[1].value );
  // Neither slider will clip the other, so make sure we determine which is larger
  if( slide1 > slide2 ){ var tmp = slide2; slide2 = slide1; slide1 = tmp; }
  
  var displayElement = parent.getElementsByClassName("rangeValues")[0];
      displayElement.innerHTML = slide1 + " - " + slide2;
}

window.onload = function(){
  // Initialize Sliders
  var sliderSections = document.getElementsByClassName("range-slider");
      for( var x = 0; x < sliderSections.length; x++ ){
        var sliders = sliderSections[x].getElementsByTagName("input");
        for( var y = 0; y < sliders.length; y++ ){
          if( sliders[y].type ==="range" ){
            sliders[y].oninput = getVals;
            // Manually trigger event first time to display values
            sliders[y].oninput();
          }
        }
      }
}
  section.range-slider {
    position: relative;
    width: 200px;
    height: 35px;
    text-align: center;
}

section.range-slider input {
    pointer-events: none;
    position: absolute;
    overflow: hidden;
    left: 0;
    top: 15px;
    width: 200px;
    outline: none;
    height: 18px;
    margin: 0;
    padding: 0;
}

section.range-slider input::-webkit-slider-thumb {
    pointer-events: all;
    position: relative;
    z-index: 1;
    outline: 0;
}

section.range-slider input::-moz-range-thumb {
    pointer-events: all;
    position: relative;
    z-index: 10;
    -moz-appearance: none;
    width: 9px;
}

section.range-slider input::-moz-range-track {
    position: relative;
    z-index: -1;
    background-color: rgba(0, 0, 0, 1);
    border: 0;
}
section.range-slider input:last-of-type::-moz-range-track {
    -moz-appearance: none;
    background: none transparent;
    border: 0;
}
  section.range-slider input[type=range]::-moz-focus-outer {
  border: 0;
}
<!-- This block can be reused as many times as needed -->
<section class="range-slider">
  <span class="rangeValues"></span>
  <input value="5" min="0" max="15" step="0.5" type="range">
  <input value="10" min="0" max="15" step="0.5" type="range">
</section>

Answer from Gary on Stack Overflow
🌐
CodePen
codepen.io › alexpg96 › pen › xxrBgbP
Double input range slider
<div class="wrapper"> <div class="values"> <span id="range1"> 0 </span> <span> &dash; </span> <span id="range2"> 100 </span> </div> <div class="container"> <div class="slider-track"></div> <input type="range" min="0" max="100" value="30" id="slider-1" oninput="slideOne()"> <input type="range" min="0" max="100" value="70" id="slider-2" oninput="slideTwo()"> </div> </div>
🌐
Muffin Man
muffinman.io › blog › native-dual-range-input
Native dual-range input · Muffin Man
November 18, 2024 - I just released @stanko/dual-range-input - a native dual-range input.
🌐
DEV Community
dev.to › sarmunbustillo › custom-double-range-slider-3h8a
Custom double range slider - DEV Community
August 14, 2022 - setStartValueCustomSlider(inputStart, inputEnd, pseudoEl, range) it includes both inputs because we need to prevent our start value to go past inputEnd's value.
🌐
Jshawl
jshawl.github.io › dual-range-input
dual-range-input
<div class="dual-range-1"> <input type="range" class="range-start" value="30" max="100"> <input type="range" class="range-end" value="60" max="100"> </div> <script type="module"> import DualRangeInput from 'https://unpkg.com/dual-range-input@latest/script.js'; DualRangeInput(".dual-range-1"); </script> Edit on Codepen ↗ ·
🌐
Figuarnieri
figuarnieri.github.io › dualrange
DualRange.js - Input range with dual values
A javascript library, without dependencies like jQuery, Zepto and etc ... Adds double values in an input range, with a callback to facilitate implementation of Min and Max values of the input, and with a minimum support for mobile
Top answer
1 of 1
115

I've been looking for a lightweight, dependency free dual slider for some time (it seemed crazy to import jQuery just for this) and there don't seem to be many out there. I ended up modifying @Wildhoney's code a bit and really like it.

function getVals(){
  // Get slider values
  var parent = this.parentNode;
  var slides = parent.getElementsByTagName("input");
    var slide1 = parseFloat( slides[0].value );
    var slide2 = parseFloat( slides[1].value );
  // Neither slider will clip the other, so make sure we determine which is larger
  if( slide1 > slide2 ){ var tmp = slide2; slide2 = slide1; slide1 = tmp; }
  
  var displayElement = parent.getElementsByClassName("rangeValues")[0];
      displayElement.innerHTML = slide1 + " - " + slide2;
}

window.onload = function(){
  // Initialize Sliders
  var sliderSections = document.getElementsByClassName("range-slider");
      for( var x = 0; x < sliderSections.length; x++ ){
        var sliders = sliderSections[x].getElementsByTagName("input");
        for( var y = 0; y < sliders.length; y++ ){
          if( sliders[y].type ==="range" ){
            sliders[y].oninput = getVals;
            // Manually trigger event first time to display values
            sliders[y].oninput();
          }
        }
      }
}
  section.range-slider {
    position: relative;
    width: 200px;
    height: 35px;
    text-align: center;
}

section.range-slider input {
    pointer-events: none;
    position: absolute;
    overflow: hidden;
    left: 0;
    top: 15px;
    width: 200px;
    outline: none;
    height: 18px;
    margin: 0;
    padding: 0;
}

section.range-slider input::-webkit-slider-thumb {
    pointer-events: all;
    position: relative;
    z-index: 1;
    outline: 0;
}

section.range-slider input::-moz-range-thumb {
    pointer-events: all;
    position: relative;
    z-index: 10;
    -moz-appearance: none;
    width: 9px;
}

section.range-slider input::-moz-range-track {
    position: relative;
    z-index: -1;
    background-color: rgba(0, 0, 0, 1);
    border: 0;
}
section.range-slider input:last-of-type::-moz-range-track {
    -moz-appearance: none;
    background: none transparent;
    border: 0;
}
  section.range-slider input[type=range]::-moz-focus-outer {
  border: 0;
}
<!-- This block can be reused as many times as needed -->
<section class="range-slider">
  <span class="rangeValues"></span>
  <input value="5" min="0" max="15" step="0.5" type="range">
  <input value="10" min="0" max="15" step="0.5" type="range">
</section>

Find elsewhere
🌐
w3collective
w3collective.com › category: tutorial › code a double range price slider using html, css & javascript
Code a double range price slider using HTML, CSS & JavaScript - w3collective
June 28, 2024 - The key thing to take note of here is the left and right positioning which are both set at 30%. You’ll see that in the HTML the initial values on the range inputs are set to 300 & 700. This CSS ensures the selected range matches these default value on page load.
🌐
The Coder Ashok
thecoderashok.com › home › blog › double range slider with min-max value using html, css, & javascript
Double Range Slider with Min-Max value using HTML, CSS, & JavaScript
February 12, 2024 - Look at these input tags type ranges, here which class name is min that is for double range slider min-value and second which class name is max that is for max-value.
🌐
Codeconvey
codeconvey.com › home › pure css range slider with 2 handles
Pure CSS Range Slider with 2 Handles | Codeconvey
September 28, 2023 - Before getting started with coding, please check out the demo page for the live test of the range slider. This double handled range slider created with HTML div elements and placed (hidden) input element to store minimum and maximum values.
🌐
Coding Artist
codingartistweb.com › home › javascript › double range slider | html, css, javascript
Double Range Slider | HTML, CSS, Javascript | Coding Artist
August 5, 2022 - <!DOCTYPE html> <html lang="en"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Double Range Slider</title> <!--Google Fonts--> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap" rel="stylesheet"> <!--Stylesheet--> <link rel="stylesheet" href="style.css"> </head> <body> <div class="wrapper"> <div class="values"> <span id="range1"> 0 </span> <span> &dash; </span> <span id="range2"> 100 </span> </div> <div class="container"> <div class="slider-track"></div> <input type="range" min="0" max="100" value="30" id="slider-1" oninput="slideOne()"> <input type="range" min="0" max="100" value="70" id="slider-2" oninput="slideTwo()"> </div> </div> <!--Script--> <script src="script.js"></script> </body> </html> We use CSS to position and style these sliders.
🌐
CSS-Tricks
css-tricks.com › multi-thumb-sliders-particular-two-thumb-case
Multi-Thumb Sliders: Particular Two-Thumb Case | CSS-Tricks
January 9, 2020 - We need two range inputs inside a wrapper. They both have the same minimum and maximum value (this is very important because nothing is going to work properly otherwise), which we set as custom properties on the wrapper (--min and --max).
🌐
Medium
medium.com › @predragdavidovic10 › native-dual-range-slider-html-css-javascript-91e778134816
Native dual range slider — HTML, CSS & JavaScript | by Predrag Davidovic | Medium
April 2, 2022 - Dual range sliders are a popular and practical solution in situations where we need to take a portion of something, for instance: “I want to present products whose prices are in matching range.” · Unfortunately there is no native HTML5 ...
🌐
CodePen
codepen.io › ChrisSargent › pen › meMMye
Dual Range Slider (Webkit)
<span class="multi-range"> <input type="range" min="0" max="50" value="5" id="lower"> <input type="range" min="0" max="50" value="45" id="upper"> </span>
🌐
Troll-Winner Blog
troll-winner.com › root › one more dual range slider
One More Dual Range Slider - Troll-Winner Blog
March 1, 2025 - Our previously made range() mixin is applied to the range inputs of our component to make them fancy and normalized. .double-range { position: relative; display: flex; flex-wrap: wrap; gap: 0 1rem; &-sliders { position: relative; flex: 100%; } &-slider { @include range(); &.is-field-from { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 1; background-color: transparent; &, &:focus { @include range-track((background-color: transparent)); } } } &-input { &-label { flex: 1 6rem; } &-field { display: block; width: 100%; } } } My little double range FromTo ·
🌐
YouTube
youtube.com › watch
Double Range Slider | HTML, CSS, Javascript | With Source Code - YouTube
Learn how you can create a dual range slider using HTML, CSS and Javascript. You can use double slider thumbs to select two values in a given range. You can ...
Published: June 6, 2021
🌐
GitHub
github.com › jahiidh › double-range-slider
GitHub - jahiidh/double-range-slider: A complete solution for double range slider. Here you can grab the slider, change via input field. It's dynamic, you can set even range step. and min value will never override the maximum and maximum as well as never get less than minimum. · GitHub
<div class="double-range"> <div class="range-slider"> <span class="range-fill"></span> </div> <div class="range-input"> <input type="range" class="min" min="0" max="100" value="30" step="1" /> <input type="range" class="max" min="0" max="100" value="70" step="1" /> </div> <div class="text-input"> <label for="min">Min</label> <input type="number" name="min" value="30" /> <label for="max">Max</label> <input type="number" name="max" value="70" /> </div> </div>
Author: jahiidh
Author: yoksel
🌐
YouTube
youtube.com › watch
Custom Double Range Slider vanilla JS | JS Range Slider - YouTube
Create Double Range Slider FlexBox, HTML, CSS and JavaScript.👉Source Code:https://www.patreon.com/fdwebdesign👉Buy Me A Coffee:https://www.buymeacoffee.com/
Published: January 5, 2023