所以基本上我试图实现这个 jsfiddle 中的内容:http: //jsfiddle.net/FPCRb/ 有一个用于一系列值的滑块和两个文本框。
这是我的 HTML 表格:
<table class="table borderless">
<thead>
<tr>
<th>Rank</th>
<th>+/-</th>
<th>Searches</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="radio" name="optradio" class="custom"> ALL</td>
<td><input type="radio" name="optradio2" class="custom2"> ALL</td>
<td><input id="slider" type="text" class="span2" value="" data-slider-min="10" data-slider-max="1000" data-slider-step="1" data-slider-value="[0,1000]" data-slider-id="RC" id="R"/></td>
<td><button id="reset" type="button" class="btn btn-success">Reset</button></td>
</tr>
<tr>
<td><input type="checkbox" class="custom-selector"> Rank 1-10</td>
<td><input type="checkbox" class="custom-selector2"> Up</td>
<td><input type="text" class="form-control form-inline col-xs-1 sliderValue" style="width: 60px" placeholder="From" data-index="0" value="10">
<label class="col-xs-1" style="font-size: 22px">→</label>
<input type="text" class="form-control form-inline col-xs-1 sliderValue" style="width: 60px" placeholder="To" data-index="1" value="90"></td>
</tr>
<tr>
<td><input type="checkbox" class="custom-selector"> Rank 11-20</td>
<td><input type="checkbox" class="custom-selector2"> Down</td>
<td><button id="reset" type="button" class="btn btn-info">Set interval</button></td>
</tr>
<tr>
<td><input type="checkbox" class="custom-selector"> Rank 21-100</td>
<td><input type="checkbox" class="custom-selector2"> No movement</td>
</tr>
<tr>
<td><input type="checkbox" class="custom-selector"> Not in top 100</td>
</tr>
</tbody>
</table>
这是我的脚本:
$(document).ready(function() {
$("#slider").slider({
min: 0,
max: 1000,
step: 1,
range: true,
values: [10, 90],
tooltip: 'always',
slide: function(event, ui) {
for (var i = 0; i < ui.values.length; ++i) {
$("input.sliderValue[data-index=" + i + "]").val(ui.values[i]);
}
}
});
$("input.sliderValue").change(function() {
var $this = $(this);
$("#slider").slider("values", $this.data("index"), $this.val());
});
});
看起来像我想要的那样,但移动滑块不会改变文本框,反之亦然,我错过了什么?