What I need:
2 ui sliders that will update when 1 of the 2, change its value.(when you drag one, the other will, too)
Both of them go from 1 to 10.
So far, if you drag one slider, the other will update with the same value.
What I need:
To display both values (they are the same) next to its respective slider.
HTML
<div id="slider-1"></div>
<div id="slider-2"></div>
<div id="amount"></div>
<div id="amount2"></div>
JS
const sliders = ['#slider-1', '#slider-2'].map(
selector => $(selector).slider({
min: 1,
max: 10,
step: 1
})
);
sliders.forEach($el => {
$el.on('slide', (_, {
value
}) => {
sliders.forEach($slider => $slider.slider('value', value));
});
});
$("#slider-1").slider({
value: 1,
slide: function(event, ui) {
$("#amount").val(ui.value);
}
});
2
Answers
Try this js:
And this is a simple example with 3 line of jQuery