Updating max value of jQuery slider from input field

对着背影说爱祢 提交于 2019-12-12 01:22:39

问题


I have a simple jquery slider, where I would like to update max:value by entering the amount in input field. Here is what I have so far:

<input name="cost" type="text" class="inputbox" size="10" id="cost" />

<label for="status">Progress Bar:</label>
    <input type="text" id="status" style="border:0; color:#158FB6;font-weight:bold; background-color:#F8F8F8" name="status"/>
    <div id="status-range" style="width: 250px;margin-top:2px"></div>

$(function() {
    $( "#status-range" ).slider({
        value:0,
        min: 0,
        max: 0,
        slide: function(event, ui) {
            $("#status").val("$" + ui.value);
        }
    });
    $("#status").val("$" + $("#status-range").slider("value"));
});

Now when user enters value in cost field I want max:0 to be updated automatically.


回答1:


Add this event listener:

$('#cost').change(function() {
  $('#status-range').slider('option','max',$(this).val());
});


来源:https://stackoverflow.com/questions/6375536/updating-max-value-of-jquery-slider-from-input-field

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