-1
Good guys, good guys! I am creating an app that counts the score of a volleyball game, but I would like to give an increment by changing the colors of the score to green for those in front, yellow to draw and red for those who are losing. For learning purposes only. The application changes the value of the scoreboard when clicked on it:
pontoA_HTML.addEventListener('click', function () {
//o que estiver aqui dentro será executado
//quando o pontoA_HTML for clicado
pontoA++;
pontoA_HTML.innerText = pontoA;
verificarFimDoSet();
});
pontoB_HTML.addEventListener('click', function () {
//o que estiver aqui dentro será executado
//quando o pontoB_HTML for clicado
pontoB++;
pontoB_HTML.innerText = pontoB;
verificarFimDoSet();
});
//Verifica o fim do set e escreve o novo valor do set
verificarFimDoSet = () => {
if (pontoA >= 21 && pontoA - pontoB >= 2) {
alert(nomeTimeA + ' venceu o set');
setA++;
setA_HTML.innerText = setA;
zerarPlacarDoSetAnterior();
verificarFimDoJogo();
}
if (pontoB >= 21 && pontoB - pontoA >= 2) {
alert(nomeTimeB + ' venceu o set');
setB++
setB_HTML.innerText = setB;
zerarPlacarDoSetAnterior();
verificarFimDoJogo();
}
can be added inside the addEventListner block ?
To improve your experience here on [pt.so], I recommend you create a [mcve] about your problem. If you just want to change the color of a text, you can [Edit] your question and put, for example, a tag
p
and a button, with your attempt to change the color in Javascript. The question has nothing to do with your volleyball game. As benefits, you will see that the question will become smaller, easier to understand and have more value for other visitors in the future.– Rafael Tavares