水平JQuery UI滑块

时间:2016-04-04 13:13:00

标签: css asp.net asp.net-mvc jquery-ui jquery-ui-slider

我想达到以下相同但水平。我尝试将方向更改为水平,甚至完全将其保留为水平,但默认为水平,但颜色默认为橙色。我正在使用ASP.NET。

Vertical slider, in which the filled bar change colour depending on how large the selected value gets

1 个答案:

答案 0 :(得分:0)

我觉得有点难以理解你想要什么100%

但我为你创建了水平。

Fiddle

Fiddle with Orange color

$(function() {

$("#slider-vertical").slider({
    orientation: "Horizontal",
    range: "min",
    min: 0,
    max: 100,
    value: 60,
    slide: function(event, ui) {
        $("#amount").val(ui.value);
        var g = parseInt(ui.value <= 50 ? 255 : 255 - ((ui.value-50)*(255/50)));
        var r = parseInt(ui.value >= 50 ? 255 : 255 - ((50-ui.value)*(255/50)));
        $(".ui-widget-header").css("background-color", "rgb("+r+","+g+",0)");  
    }
});
$("#amount").val($("#slider-vertical").slider("value"));
});