Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

368
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!