Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize the color of the jquery slider range?

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;
}
like image 243
FiveTools Avatar asked Dec 17 '22 09:12

FiveTools


1 Answers

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.

like image 158
Jon Avatar answered Jan 13 '23 09:01

Jon