2011-06-16 60 views
0

我有一個簡單的jQuery滑塊,我想通過在輸入字段中輸入數量來更新max:value。這是我到目前爲止:從輸入字段更新jQuery滑塊的最大值

<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")); 
}); 

現在,當用戶在成本字段中輸入值我想max:0自動更新。

回答

1

添加此事件偵聽器:

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

謝謝你,但你的解決方案不起作用。我希望能夠通過輸入成本字段來控制最大值 – Alex 2011-06-16 17:20:41

+0

更新了代碼。對不起,錯字。 – js1568 2011-06-16 17:34:23

+0

非常感謝。完美的作品。 – Alex 2011-06-16 17:58:04