How to customize the color of the jquery slider range?

帅比萌擦擦* 提交于 2020-02-24 03:56:08

问题


When using the jquery slider, I would like to change the default color of the selected range from grey to blue.

$(document).ready(function () {

            var slider = $('.slider').slider({
                range: "min",
                min: 0,
                max: 100,
                change: function (e, ui) {
                    //                    $("#img1").fadeOut();
                    //                    alert("done");
                },
                slide: function (e, ui) {
                    var point = ui.value;
                    $("#selected_value").html(point);
                    var width = 100 - point;
                   $("#range").css({ "width": point + "%" });
                }

            });

my html:

<div>
        Min: <span id="selected_value">0</span><br />

    </div>
    <div>
        <div class="slider"><div id="range"></div></div>
    </div>

and my css:

#range
{
    position:absolute;
    height:100%;
    top: 0;
    background-color:Blue;
}

回答1:


You need to specify this with CSS:

div.ui-slider-range.ui-widget-header {
    background: blue;
}

If you only want to target a subset of your sliders, restrict the selector accordingly.

See it in action.




回答2:


LOOK AT THIS FOR SOLUTION

.ui-widget-header{background-image:none;background-color:#A157A4;}
.ui-widget-content { background: #FFCCCC; }



回答3:


If you have a slider range use this in the slider function to change the UI

$("#slider-range .ui-slider-range").css({"background":"#ef2929"});

$("#slider-range .ui-slider-handle").css({"border-color":"#ef2929"});


来源:https://stackoverflow.com/questions/7436849/how-to-customize-the-color-of-the-jquery-slider-range

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!