I have 3 jQuery sliders on the same page:-
jQuery('.slider-deposit').slider({
range: "max",
min: 3800,
max: 30000,
value: 3848,
step: 500,
slide: function(event, ui) {
jQuery(".calc-deposit").html('£'+ui.value);
});
jQuery('.slider-loan').slider({
range: "max",
min: 15400,
max: 120000,
value: 15393,
step: 2000,
slide: function(event, ui) {
jQuery(".calc-loan").html('£'+ui.value);
}
});
jQuery('.slider-mortgage').slider({
range: "max",
min: 57000,
max: 450000,
value: 57724,
step: 7500,
slide: function(event, ui) {
jQuery(".calc-mortgage").html('£'+ui.value);
}
});
On change on ANY of the sliders I want to update a value on the page, how can this be achieved?
I did try:-
jQuery('.slider').slider({
slide: function(event, ui) {
alert('test');
}
});
But this doesn't work.
You can DRY up your code by using
dataattributes on the HTML element you instantiate the slider on. This will then allow you to run the same code on theslideevent of all three. Try this:Example fiddle