Ok. I got it solved.
I added loop, so, Javascript goes through all divs.
Here's the code:
<div id="watupro_quiz" class="quiz-area single-page-quiz">
<div id="startOutput"> </div>
<!--<script type="text/javascript" src="https://psy-help.ee/wp-content/scripts/test_results.js"></script>-->
<div class="bar" data-score="71" data-less="47" data-more="70">
<div class="wppb-wrapper ">
<div class="wppb-progress fixed"><span class="yellow" style="width: 39.230769230769%;"><span></span></span></div>
</div>
</div>
<div class="bar" data-score="62">
<div class="wppb-wrapper ">
<div class="wppb-progress fixed"><span class="yellow" style="width: 47.692307692308%;"><span></span></span></div>
</div>
</div>
<!--<script type="text/javascript">
results();-->
</script>
</div>
div.wppb-wrapper {
clear: both;
}
div.wppb-progress {
height: 25px;
width: 400px;
background: #555;
-moz-border-radius: 30px;
-o-border-radius: 30px;
border-radius: 30px;
position: relative;
}
div.wppb-progress > span.green {
background: #83c783;
background: -moz-linear-gradient(top, #83c783 0%, #52b152 33%, #008a00 62%, #005700 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#83c783), color-stop(33%,#52b152), color-stop(62%,#008a00), color-stop(100%,#005700));
background: -webkit-linear-gradient(top, #83c783 0%,#52b152 33%,#008a00 62%,#005700 100%);
background: -o-linear-gradient(top, #83c783 0%,#52b152 33%,#008a00 62%,#005700 100%);
background: -ms-linear-gradient(top, #83c783 0%,#52b152 33%,#008a00 62%,#005700 100%);
background: linear-gradient(to bottom, #83c783 0%,#52b152 33%,#008a00 62%,#005700 100%);
}
div.wppb-progress > span {
display: block;
height: 25px;
-moz-border-radius: 30px;
-o-border-radius: 30px;
border-radius: 30px;
background: #5a84c4;
background: -moz-linear-gradient(top, #5a84c4 0%, #1a2275 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#5a84c4), color-stop(100%,#1a2275));
background: -webkit-linear-gradient(top, #5a84c4 0%,#1a2275 100%);
background: -o-linear-gradient(top, #5a84c4 0%,#1a2275 100%);
background: -ms-linear-gradient(top, #5a84c4 0%,#1a2275 100%);
background: linear-gradient(top, #5a84c4 0%,#1a2275 100%);
-webkit-box-shadow: inset 0 2px 9px rgb(255 255 255 / 30%), inset 0 -2px 6px rgb(0 0 0 / 40%);
-moz-box-shadow: inset 0 2px 9px rgba(255,255,255,0.3), inset 0 -2px 6px rgba(0,0,0,0.4);
box-shadow: inset 0 2px 9px rgb(255 255 255 / 30%), inset 0 -2px 6px rgb(0 0 0 / 40%);
overflow: hidden;
position: relative;
}
let barElement = document.getElementsByClassName("bar");
for (let i = 0; i < barElement.length; i++) {
let wrapper = barElement[i].firstElementChild;
let bar = wrapper.firstElementChild;
let span = bar.firstElementChild;
let score = barElement[i].getAttribute("data-score");
let low = barElement[i].getAttribute("data-less");
let high = barElement[i].getAttribute("data-more");
if (score < low) {
span.classList.remove("yellow");
span.classList.add("green");
} if (score > high) {
span.classList.remove("yellow");
span.classList.add("red");
}
}
Working example here: https://codepen.io/nick-gregory-the-looper/pen/wvympmg