jQuery Mobile 双范围 slider

标签 jquery html jquery-mobile

我在 JQM 中制作了一个双范围 slider ,方法是将 slider 放在彼此的顶部。有什么方法可以阻止最小值超过最大值?

我不确定 slider 是否使用 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 有一个很棒的双 slider ,可以与 JQM 完美配合!!!

http://developer.yahoo.com/yui/examples/slider/slider_dual_with_highlight.html

最佳答案

这样的东西会工作吗:

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

关于jQuery Mobile 双范围 slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8895748/

相关文章:

javascript - Fancytree如何选择/取消选择所有克隆节点

html - div 在屏幕上高于父 div 时被截断

javascript - 动态添加 HTML 到 jquery mobile 后刷新一个部分

javascript - html5 将文件拖动到输入 - 我可以多次拖动到同一输入中并添加文件而不是替换文件吗?

javascript - 如何获取十六进制数字的 jQuery Mobile slider ?

javascript - JQM 1.4.0 上的自定义转换设置出现 "has no method ' 转换 '"错误?

jquery - 默认情况下切换点击隐藏

javascript - SHOPIFY 页面中 slider 下方的 Flexslider 缩略图(不是产品图片)

javascript - 倒数计时器重置转换

javascript - 表单验证未显示