jRange 滑块插件销毁方法

2018-11-21 22:15:55
769次阅读
0个评论
<div class="demo-output">
    <button id="change-btn">Change Range</button>
    <br><br>
        <hr>
            <br><br>
     <input class="single-slider" type="text" value="25"/>
</div>
.demo-output{
    width: 300px;
    margin: 100px auto;
}
.single-slider{
    display:none;
}

将下限由28改为50


$(document).ready(function(){
    $('.single-slider').jRange({
        from: 1,
        to: 28,
        step: 1,
        format: '%s',
        width: 375,
        showLabels: true,
        showScale: true,
        onstatechange: function(val){
             $('#now-value').val(val);      
        }
    });
    
    $('#change-btn').click(function(){
        $('.single-slider').removeData('plugin_jRange');
        $('.single-slider').next().remove();
        $('.single-slider').jRange({
            from: 1,
            to: 50,
            step: 1,
            format: '%s',
            width: 375,
            showLabels: true,
            showScale: true,
            onstatechange: function(val){
                 $('#now-value').val(val);      
            }
        });
    });





收藏00

登录 后评论。没有帐号? 注册 一个。