Usuario:RubiVGM/statsDynamicColors

De Unión PokéPRO - Wiki
Revisión del 21:27 28 ene 2025 de RubiVGM (discusión | contribs.) (Página creada con «// Función para cambiar el color de las barras según su valor document.addEventListener('DOMContentLoaded', function() { document.querySelectorAll('.stat-bar').forEach(function(bar) { var value = parseInt(bar.getAttribute('data-value')); // Obtiene el valor de la estadística if (value < 50) { bar.style.backgroundColor = '#ff5959'; // Rojo } else if (value >= 50 && value < 100) { bar.style.backgroundColor = '#fae078'; // Naranja } el…»)
(difs.) ← Revisión anterior | Revisión actual (difs.) | Revisión siguiente → (difs.)
Ir a la navegaciónIr a la búsqueda

// Función para cambiar el color de las barras según su valor document.addEventListener('DOMContentLoaded', function() {

 document.querySelectorAll('.stat-bar').forEach(function(bar) {
   var value = parseInt(bar.getAttribute('data-value'));  // Obtiene el valor de la estadística
   if (value < 50) {
     bar.style.backgroundColor = '#ff5959';  // Rojo
   } else if (value >= 50 && value < 100) {
     bar.style.backgroundColor = '#fae078';  // Naranja
   } else {
     bar.style.backgroundColor = '#a7db8d';  // Verde
   }
 });

});