I am trying to get access to the changing values of a series of HTML range sliders.
Here is how they're instantiated:
<li *ngFor="let rgbVal of rgbVals; let i=index">
{{i}}: {{rgbVal}} <br>
<div class="color-box" [style.backgroundColor]="rgbVal"></div>
<div class="slideContainer" >
<input type="range" min="1" max="100" value="30" class="slider" id="shade{{i}}" step="1" (change) = "update(i)" >
</div>
</li>
This is the Typescript function I have in my .ts function that should be able to access the value of the sliders:
update(i){
var id = "shade"+i;
var slider = document.getElementById(id);
console.log(slider.getAttribute("value"));}
The value once I move the slider stays constant & unchanged, no matter which slider I move or how much I move it.
Interestingly enough, if I run this code:
update(i){
var sliders = document.getElementsByClassName("slider");
console.log(sliders);}
And then in the console open up the HTML container and look at the value field of each slider, it is updated as I move it.
I also tried
slider = sliders[i];
console.log(slider.getAttribute("value");
And that stayed constant regardless of change, even though that slider when viewed as a part of the sliders object allowed the value to be updated.
I am baffled by this one and can't find any similar errors online, so any help would be greatly appreciated.