When adjusting the sliders, the input fields are supposed to update accordingly. However, I've noticed that the changes in the input fields only take effect if I manually change their values. The automatic reflection doesn't seem to occur when using the sliders.
So, when I change the input value directly, the changes reflect properly. But when I adjust the slider value, which should then update the input field value, this reflection does not happen as expected.
var rSlider = document.querySelector("#r");
var gSlider = document.querySelector("#g");
var bSlider = document.querySelector("#b");
var rInput = document.querySelector('#rInput');
var gInput = document.querySelector('#gInput');
var bInput = document.querySelector('#bInput');
$(document).ready(function() {
$(rInput).val(0);
$(gInput).val(0);
$(bInput).val(0);
})
$(rSlider).on('input', function() {
$(rInput).val($(this).val());
})
$(gSlider).on('input', function() {
$(gInput).val($(this).val());
})
$(bSlider).on('input', function() {
$(bInput).val($(this).val());
})
$(rInput, gInput, bInput).change(function() {
rValue = String($(rInput).val());
gValue = String($(gInput).val());
bValue = String($(bInput).val());
var tempString = `rgb(${rValue},${gValue},${bValue})`
console.log(tempString)
})
Interestingly, the console.log statement is only triggered in the first scenario and not in the second case. Any assistance with this issue would be greatly appreciated. Thank you in advance.