我通过将滑块放在彼此的顶部,在JQM中制作了双范围滑块。有没有办法可以阻止min超过最大值?
我不确定滑块是否使用HTML5范围输入类型
<style type="text/css">
.priceRangeInfo{
position: relative;
height: 30px;
margin-top: 60px;
}
.priceRangeInfo label{
position: absolute;
top: -30px;
left: 10px;
} /* moves label field */
.priceRangeInfo #buying_slider_min{
top: -40px;
position: absolute;
left: 100px;
} /* moves first input field */
.priceRangeInfo #buying_slider_max{
top: -40px;
position: absolute;
left: 170px;
} /* move second input field */
.priceRangeInfo div.ui-slider{
position: absolute;
} /* move both sliders - adressing 1st slider with CSS is hard */
.priceRangeInfo div:last-child{
position: absolute;
left: 0px;
} /* correct 2nd slider position to fit exactly on top of 1st slider */
</style>
<div class="priceRangeInfo">
<label for="buying_slider_min">Price</label>
<input type="range" name="buying_slider_min" id="buying_slider_min" class="minBuyingSlider" value="0" min="0" max="100" />
<input type="range" name="buying_slider_max" id="buying_slider_max" class="maxBuyingSlider" value="100" min="0" max="100" />
</div>
刚刚发现YUI有一个很棒的双滑块,可以与JQM完美配合!!!
http://developer.yahoo.com/yui/examples/slider/slider_dual_with_highlight.html
答案 0 :(得分:3)
这样的事情会起作用吗?
JS
$('#buying_slider_min').change(function() {
var min = $(this).val();
var max = $('#buying_slider_max').val();
if(min > max) {
$('#buying_slider_max').val(min);
$('.maxBuyingSlider').slider('refresh');
}
});
HTML
<div class="priceRangeInfo">
<label for="buying_slider_min">Price</label>
<input type="range" name="buying_slider_min" id="buying_slider_min" class="minBuyingSlider" value="0" min="0" max="100" />
<input type="range" name="buying_slider_max" id="buying_slider_max" class="maxBuyingSlider" value="100" min="0" max="100" data-track-theme="b"/>
</div>
CSS
.priceRangeInfo{
position: relative;
height: 30px;
margin-top: 60px;
}
.priceRangeInfo label{
position: absolute;
top: -30px;
left: 10px;
} /* moves label field */
.priceRangeInfo #buying_slider_min{
top: -40px;
position: absolute;
left: 100px;
} /* moves first input field */
.priceRangeInfo #buying_slider_max{
top: -40px;
position: absolute;
left: 170px;
} /* move second input field */
.priceRangeInfo div.ui-slider{
position: absolute;
} /* move both sliders - adressing 1st slider with CSS is hard */
.priceRangeInfo div:last-child{
position: absolute;
left: 0px;
}
答案 1 :(得分:0)
你必须创建滑块,以便: HTML:
<div id="slider-container-zucker" class="slider_style"></div>
和js:
$(function () {
$('#slider-container-zucker').slider({
range: true,
min: 0,
max: 9,
values: 0, 9,
change: function (event, ui) {
$.ajax({
type: "GET",
url: url,
success: function (result) {
$("#Result").html(result);
}
});
}
});
});
如果有什么不清楚,你可以问我