How to reset a jQuery UI slider?

后端 未结 5 1831
梦毁少年i
梦毁少年i 2021-02-07 05:50
    
    
    

        
5条回答
  •  梦谈多话
    2021-02-07 06:13

    You may try as

    function PrimarySlider() {  
     $( "#slider-range" ).slider({
                range: true,
                min: 0,
                max: 500,
                values: [ 75, 300 ],
                slide: function( event, ui ) {
                    $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
                }
            });
            $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
                " - $" + $( "#slider-range" ).slider( "values", 1 ) );
        });
    
    }  
    

    call the function PrimarySlider(); whenever you need slider and reset by calling

    function ResetPrimarySlider() {
       $( "#slider-range" ).slider("destroy");
       PrimarySlider();
    }
    

提交回复
热议问题