The CSS code in my stylesheet is customized to style the progress bar in Google Chrome with a gradient effect.
progress[value] {
width: 100%; height: 40px;
margin: 0 0 3em;
border: 4px solid #000000;
}
progress::-webkit-progress-value {
background-image:
-webkit-linear-gradient(-45deg,
transparent 33%, rgba(0, 0, 0, .1) 44%,
rgba(0,0, 0, .1) 66%, transparent 66%),
-webkit-linear-gradient(top,
rgba(255, 255, 255, .25),
rgba(0, 0, 0, .25)),
-webkit-linear-gradient(right, #04d647, #009999);
}
However, my JavaScript code is causing the progress bar to change values continuously. Currently set to a green gradient, I want to modify it to display different colors based on percentage values (e.g., less than 30% = red, between 30%-65% = yellow, and more than 65% = green).
I have some basic JavaScript code in my HTML file to get started, but I'm unsure how to dynamically change the gradient colors within progress::-webkit-progress-value based on the value range. The challenge lies in modifying a pseudo-element like webkit-progress using JS.
if (progressbar1.value >= .30) {
$("progress::-webkit-progress-value").css("background-color", "#424242");
// How can I achieve this? Are there specific tags or scripts needed?
}
What am I missing here?