Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

376
Vistas
Javascript - How to compare tables cell background color to specific color code

I am looping into html tables cell and I would like to check the cells color if it is equal to a specific color code.

if I alert 'cell.style.backgroundColor' I get the result of rgb(0,0,0) But if I check it like this :

   if(cell.style.backgroundColor=="#000")
    {
      alert("ok");
    }      

or this one :

    if(cell.style.backgroundColor=="rgb(0,0,0)")
     {
       alert("ok");
     } 

I always get false.

Any ideas?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You have to add the spaces after the commas: "rgb(0, 0, 0)" not "rgb(0,0,0)"

about 4 years ago · Juan Pablo Isaza Denunciar

0

Try it:

window.getComputedStyle(cell, null).backgroundColor

And test it in different browsers, maybe each one can get with different kind of format.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda