<script type="text/javascript">
var students = document.querySelectorAll("#student");
var label = document.querySelectorAll("label");
var button = document.querySelector("button");
button.addEventListener("click",function(){
for(var i = 0; i < students.length; i++){
for(var j = 0; j < label.length; j++){
if (students[i].value >= 70 && students[i].value <= 100){
label[j].style.backgroundColor = "green";
}else if (students[i].value >= 50 && students[i].value < 70){
label[j].style.backgroundColor = "blue";
}else if (students[i].value >= 35 && students[i].value < 50){
label[j].style.backgroundColor = "yellow";
}else{
label[j].style.backgroundColor = "red";
}
}
}
});
</script>
/There is Problem in java-script code and for loops/ /Selecting elements from HTML works fine/
Aucun commentaire:
Enregistrer un commentaire