Untitled

 avatar
unknown
plain_text
2 years ago
1.1 kB
3
Indexable
function changeTheValue(id,teamId) {
  
  if(document.getElementById(id).innerText == "X") {
    document.getElementById(id).innerText = ""

    let colorValue = parseInt(document.getElementById(teamId).innerText)
    colorValue = colorValue - 1;
    document.getElementById(teamId).innerText = colorValue
    changeTheColor(teamId);
  } else {
    document.getElementById(id).innerText = "X"

    let colorValue = parseInt(document.getElementById(teamId).innerText)
    colorValue = colorValue + 1;
    document.getElementById(teamId).innerText = colorValue
    changeTheColor(teamId);
  }
 
}

function changeTheColor(id) {
  let totaltValue1 = parseInt(document.getElementById(id).innerText)
  console.log(totaltValue1  + "totaltValue1 = " + totaltValue1)
  if(totaltValue1 == '1'){
    document.getElementById(id).style.backgroundColor = "yellow";
  } else if(totaltValue1 == '0'){
    document.getElementById(id).style.backgroundColor = "red";
  } else {
    document.getElementById(id).style.backgroundColor = "green";
  }
}
Editor is loading...