我使用JQuery UI增量滑块构建了一个评级表单,除了我的值是单词而不是数字。但是,初始值仍显示为数字。我尝试将value="0"
更改为value="Not Yet Rated"
但最终会破坏滑块。
任何和所有帮助表示赞赏。
<html>
<div class="kpa_rate kpa_rate1">
<label for="kpa1_rating_value">Parking:</label>
<div id="1" class="slider"></div>
<input type="text" class="kpa1_rating_value" name="kpa1_rating" value="0" />
</div>
<div class="kpa_rate kpa_rate2">
<label for="kpa2_rating_value">Entrance:</label>
<div id="2" class="slider"></div>
<input type="text" class="kpa2_rating_value" name="kpa2_rating" value="0" />
</div>
</html>
的JavaScript
<script>
$(function() {
var Array = ["Poor Accesibility","Okay Accessibility", "Moderate Accessibility", "Good Accessibility","Great Accessibility"];
$( ".slider" ).slider({
range: "max",
min: 0,
max: 4,
value: $("input", this).val(),
slide: function( event, ui ) {
//get the id of this slider
var id = $(this).attr("id");
//select the input box that has the same id as the slider within it and set it's value to the current slider value.
$("input[class*=" + id + "]").val(Array[ui.value]);
}
});
});
</script>
答案 0 :(得分:0)
您的实际代码中似乎不存在value: $("input", this).val(),
。
尝试值:$(this).parent().next().next().find('input').val(),