i want jquery ui slide with range 1 to 5 with value showing
Here's an example of how to create a jQuery UI slider with a range of 1 to 5 and display the selected value:
HTML:
<p>
<label for="slider">Select a value:</label>
<input type="text" id="sliderValue" readonly>
</p>
<div id="slider"></div>
JavaScript:
$(function() {
// Create slider with range 1 to 5
$('#slider').slider({
range: true,
min: 1,
max: 5,
values: [1, 5],
slide: function(event, ui) {
// Update text box with selected values
$('#sliderValue').val(ui.values[0] + ' - ' + ui.values[1]);
}
});
// Set initial value of text box
$('#sliderValue').val($('#slider').slider('values', 0) + ' - ' + $('#slider').slider('values', 1));
});
This code creates a slider with a range from 1 to 5, and sets the initial selected values to 1 and 5. The slide function is called whenever the slider is moved, and updates the text box with the selected values. The initial value of the text box is set to the initial selected values of the slider.
原文地址: https://www.cveoy.top/t/topic/bNmd 著作权归作者所有。请勿转载和采集!