如何用灰色标记html范围滑块(所有已选择的区域)

How to mark the html range slider with a gray color(all area that have been selected)?

本文关键字:选择 区域 灰色 何用 html 范围      更新时间:2023-09-26

我使用html,css, bootstrap 3, javascript/jquery。当用户增加滑块拇指时,我想用与滑块背景颜色不同的颜色标记html范围滑块。

.ios-range-slider {
    -webkit-appearance: none;
    border-radius: 10px;
    background-color: #C1C9C8;
    width: 100%;
}

input[type="range"]::-webkit-slider-thumb{
     -webkit-appearance: none;
    background-color: white;
    border-radius: 10px;
    width: 15px;
    height: 15px;    
}

一个非常简单的解决方案是使用jQuery。

$(document).ready(function(){
    $(".ios-range-slider").change(function(){
        var val = $(this).val();
        $(this).css("background-color","rgb("+(val*10)+","+(val*10)+","+(val*10)+")");
    });
});