最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dual range slider without using jQuery - Stack Overflow

programmeradmin3浏览0评论

I want to create a dual range UI slider without using jQuery, most of the dual range sliders have dependency of jQuery and I can't use jQuery in my project. I tried overlapping 2 range inputs but I am stucked at CSS and functionality. Is there any way to make non jQuery dual range slider? Ref- /

I want to create a dual range UI slider without using jQuery, most of the dual range sliders have dependency of jQuery and I can't use jQuery in my project. I tried overlapping 2 range inputs but I am stucked at CSS and functionality. Is there any way to make non jQuery dual range slider? Ref- http://refreshless./nouislider/

Share Improve this question asked Dec 17, 2013 at 8:41 nickalchemistnickalchemist 2,2417 gold badges32 silver badges58 bronze badges 5
  • What is the reason you cannot use JQuery? I do not understand if javascript is allowed but JQuery isn't. JQuery is javascript... – Squirrel5853 Commented Dec 17, 2013 at 8:43
  • My application is size-sensitive. I don't want to add any extra libraries. – nickalchemist Commented Dec 17, 2013 at 8:49
  • @Nickalchemist Whilst that's true, but you can make it only include the Slider UI and nothing else. – MackieeE Commented Dec 17, 2013 at 8:58
  • @MackieeE So there is no way I can make a dual slider without using jQuery. Anyone modified non-UI slider library and converted it to native Javascript? – nickalchemist Commented Dec 17, 2013 at 10:27
  • @Nickalchemist Of course you can, just if you did developed one bespokely with Vanilla Js, it would probably/likely entail the same line of implementation as jQuery UI Slider in the end. – MackieeE Commented Dec 17, 2013 at 12:12
Add a ment  | 

4 Answers 4

Reset to default 6

There doesn't seem to be any JS range slider around that's not made using jQuery. I'd suggest to use noUiSlider, which at least doesn't depend on jQuery UI.

PS: jQuery UI with slider only: 24kb, noUiSlider: 10kb. And it even has more/better functionality imo.

You could give fdSlider a try. It does not depend on any other library.

Here is an only HTLM/CSS dual slider with custom styling:

CSS:

                .slider {
                    -webkit-appearance: none;
                    width: 90%;
                    height: 25px;
                    position: absolute;
                    background: #a4a4a4;
                    outline: none;
                }

                .slider input {
                    pointer-events: none;
                    position: absolute;
                    overflow: hidden;
                    left: 25%;
                    top: 15px;
                    width: 50%;
                    outline: none;
                    height: 18px;
                    margin: 0;
                    padding: 0;

                }

                .slider::-webkit-slider-thumb {
                    -webkit-appearance: none;
                    appearance: none;
                    width: 35px;
                    height: 35px;
                    background: #ea4550;
                    cursor: pointer;

                    pointer-events: all;
                    position: relative;
                    z-index: 1;
                    outline: 0;
                }

                .slider::-moz-range-thumb {
                    width: 20px;
                    height: 20px;
                    background: #ea4550;
                    cursor: pointer;

                    pointer-events: all;
                    position: relative;
                    z-index: 10;
                    -moz-appearance: none;
                    width: 9px;
                }

                .slider input::-moz-range-track {
                    position: relative;
                    z-index: -1;
                    border: 0;
                }
                .slider input:last-of-type::-moz-range-track {
                    -moz-appearance: none;
                    background: none transparent;
                    border: 0;

                }
                .slider input[type=range]::-moz-focus-outer {
                border: 0;
                }

HTML:

<input type="range" min="12" max="2175" value="12" class="slider" id="lower">
<input type="range" min="12" max="2175" value="2175" class="slider" id="higher">

You can code your own custom dual slider (html, css and the javascript) but I'm sure that using a jquery plugin is the best approach

发布评论

评论列表(0)

  1. 暂无评论