Range Slider
How do I make an range slider?
By Rachael Smith. What is a range slider? How do you make a range slider? This script and codes were developed by UX Snippets on 27 October 2022, Thursday.
Range Slider - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Range Slider</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <!--
Copyright (c) 2016 Rachael Smith
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<div class="range"> <input class="range-slider" id = "range-slider" type="range" min="0" max="8" step="1" value="0" /> <ul id="labelList"> <li class="label active">A-C</li> <li class="label">D-F</li> <li class="label">G-I</li> <li class="label">J-L</li> <li class="label">M-O</li> <li class="label">P-R</li> <li class="label">S-U</li> <li class="label">V-X</li> <li class="label">Y-Z</li> </ul>
</div> <script src='https://code.jquery.com/jquery-2.2.4.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Range Slider - Script Codes CSS Codes
body { padding: 40px;
}
.range-slider { -webkit-appearance: none; background: transparent; width: 100%; cursor: pointer;
}
.range-slider::-webkit-slider-runnable-track { width: 100%; height: 15px; background: #f2f2f2;
}
.range-slider::-webkit-slider-thumb { height: 25px; width: 8%; background: #07579e; -webkit-appearance: none; margin-top: -5px;
}
.range-slider:focus { outline: none;
}
ul { padding: 0; margin: 15px 0 0; width: 100%; display: -webkit-box; display: -ms-flexbox; display: flex; list-style: none; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between;
}
ul li { display: block; text-align: center; width: 8%;
}
ul li.label { color: #ccc; cursor: pointer; list-style: none;
}
ul li.label:hover, ul li.label.active { color: #07579e;
}
Range Slider - Script Codes JS Codes
$(".range-slider").change(function() { slider = $(this); activeLabel = (slider.val()); $('li.label').removeClass('active'); $('li.label:eq('+activeLabel+')').addClass('active');
});
$('li.label').bind('click', function(){ label = $(this); sliderval = label.index(); $("input[type='range']").val(sliderval) for(var i = 0; i < $("input[type='range']").attr("max"); i++) { if(i != sliderval && $("li.label").eq(i).hasClass("active")){ $("li.label").eq(i).removeClass('active'); } } if($("li.label").eq(0).hasClass("active")){ $("li.label").eq(0).removeClass('active'); } maxVal = document.getElementById("range-slider").max; if($("li.label").eq(maxVal).hasClass("active")){ $("li.label").eq(maxVal).removeClass('active'); } $("li.label").eq(sliderval).addClass("active");
});
Developer | UX Snippets |
Username | appirio-ux |
Uploaded | October 27, 2022 |
Rating | 3 |
Size | 3,471 Kb |
Views | 38,456 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Scroll Progress | 11,312 Kb |
Responsive table with data-labels | 2,925 Kb |
Button examples | 4,396 Kb |
A Pen by UX Snippets | 1,581 Kb |
Email Sample | 2,749 Kb |
Weekly Email - 02 | 3,488 Kb |
Appirio Demos | 4,466 Kb |
Fancyselect Sample | 5,197 Kb |
Clone the things | 2,684 Kb |
Update for IE11 support | 4,529 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Practice using Wixel | Emnk | 3,057 Kb |
Elon Musk - Tribute Page - FreeCodeCamp | Yunnimun | 8,615 Kb |
Hard-Stop Gradients | Mackdoyle | 2,288 Kb |
Count checked checkboxes with jQuery | Mestika | 2,343 Kb |
Rotate Demo | Agelber | 3,061 Kb |
SVG Text Masking | JMChristensen | 2,141 Kb |
Knob rotation | Alemesre | 2,122 Kb |
A Pen by Michael Parenteau | Michaelparenteau | 2,133 Kb |
Template | Indra_z85 | 2,323 Kb |
Toolbar | Onsen | 5,414 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!