jQuery UI Slider: How to Make the Slider Move in Increments
To make the slider move in increments of 50000, you can add the 'step' option to the slider configuration:
$(function() {
$( '#slider-range' ).slider({
range: true,
min: 0,
max: 50000000,
step: 50000, // Set the step value to 50000
values: [ 0, 50000000 ],
slide: function( event, ui ) {
$( '#amount' ).html( '$' + ui.values[ 0 ] + ' - $' + ui.values[ 1 ] );
$( '#min' ).val(ui.values[ 0 ]);
$( '#max' ).val(ui.values[ 1 ]);
$(ui.handle).attr('data-value', ui.value); // Update handle popup value
$('#qp_has_price').attr('data_value', ui.values[ 0 ]+'to'+ui.values[ 1 ]);
$('.qq_price_range .qq_selected_terms').html( ui.values[ 0 ]+','+ui.values[ 1 ]);
$('.qq_clear_all_filters').prop('disabled', false);
setQueryStringParameter('price', ui.values[ 0 ]+'to'+ui.values[ 1 ]);
qq_call_loads();
}
});
$( '#amount' ).html( '$' + $( '#slider-range' ).slider( 'values', 0 ) +
' - $' + $( '#slider-range' ).slider( 'values', 1 ) );
// Initialize handle popups with default values
$('#slider-range .ui-slider-handle').each(function() {
$(this).attr('data-value', $(this).slider('value'));
});
});
With this code, the slider will move in increments of 50000 as you make selections.
原文地址: https://www.cveoy.top/t/topic/qf54 著作权归作者所有。请勿转载和采集!