I am completely new to html, css, and javascript. My goal is to create a color gradient bar and then place a dot on it based on a variable. I tried to implement a solution I found from various sources, but it is not functioning as expected, and I am seeking help to understand the issue.
var A = 38,
B = 100,
C = 0,
D = 300,
score = 67; // {{crFlag['value']}} will be variable
function init() {
$('.circle').attr('style', 'left: ' + ((score - A) / (B - A) * (D - C)) + 'px');
};
.container {
position: relative;
display: flex;
width: 300px;
height: 16px;
border: 1px solid #7c7676;
background-image: linear-gradient(to right, #4cd964, #d0ff00, #e0740f, #ff2d55);
}
.circle {
background: rgba(88, 83, 83);
width: 10px;
height: 16px;
border-radius: 30%;
position: absolute;
left: 40px;
}
<div class="container">
<div class="circle"></div>
</div>
Why is the position of the dot not changing when I update the score variable?