Jquery UI Range - Add Plus symbol

余生颓废 提交于 2019-12-12 04:26:10

问题


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:


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



来源:https://stackoverflow.com/questions/16357256/jquery-ui-range-add-plus-symbol

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