Jquery UI Range - Add Plus symbol

2019-08-22 07:35发布

Im currently building a project planner form for a client, i Am using Jquery UI for a range slider.

I am struggling to figure out how to make it so that when the range value is at Max, it adds a Plus(+) to after the value in the input field.

My current script is

function projectPlannerSlider() {

    $("#budgetSlider").slider({
        range: "min",
        min: 100,
        max: 25000,
        value: 7000,
        slide: function (event, ui) {
            $(".budget").val("\u00A3" + ui.value);
        }
    });
    $(".budget").val("\u00A3" + $("#budgetSlider").slider("value"));

};

and my HTML is

<h3>Budget</h3>
<div id="budgetSlider"></div>
<asp:TextBox ID="budget" CssClass="budget clearStyling" runat="server" />

Any help would be very much appreciated. Cheers Jordan

1条回答
Emotional °昔
2楼-- · 2019-08-22 08:15

Try this:

$("#budgetSlider").slider({
    range: "min",
    min: 100,
    max: 25000,
    value: 7000,
    slide: function (event, ui) {
        $(".budget").val((ui.value == '25000') ? (ui.value + '+') : ui.value);
    }
});

$(".budget").val($("#budgetSlider").slider("value"));

FIDDLE DEMO HERE

查看更多
登录 后发表回答