Solution 1 :

this is the suedo code and you can change it according to your requirements. this is just to give you an idea of how to do it.

<table style="width:100%">
    <td class="LightBlue">Firstname</td>
    <td class="LightGreen">Lastname</td>
    <td class="LightBlue">whatever</td>
    <td class="LightGreen">youfill</td>
<button class="btn btn-success styled1" onclick="changeColor()"  type="button">Validate</button>

            function changeColor() { 
              var greenTD = document.getElementByClassName("LightGreen"); 
              var BlueTD= document.getElementByClassName("LightBlue");
     = "green"; 
     = "Blue";   

Solution 2 :

<table style="width:100%">
    <td [ngClass]="buttonClicked ?'yourClass':''">Firstname</td>
<button class="btn btn-success styled1" onclick="buttonClicked = !buttonClicked"  type="button">Validate</button>

you can use like this ngClass that is you need to initialize the buttonClicked in your TS file and make it initially as false
it will work

Problem :

how to make a function when I add click() in my button Validate my cells (td) of Table so put changes of color for example green cell -> green light blue light cell ->blue red cell -> dark red

<button    class="btn btn-success styled1"  type="button">   Validate </button>


Comment posted by Rarex

This isn’t a place for asking people to code for you. Please provide something you tried yourself.

Comment posted by Mohamed h

but My td is made like that :

Comment posted by link

If you only wish to lighten or darken the color. It can be done by manipulating the Hexadecimal Values of colors.

Comment posted by Bilal Bin Zia

@Mohamedh btw, how are you implementing different colors to different cell?

Comment posted by Mohamed h

when I click on a cell there is a pop up that appears and I choose a color green red blue ect … and the box changes color my colors are CSS classes and initially all the cells of the table are green

Comment posted by Mohamed h

how to make my button recognize my function change color which is in my script

Comment posted by Mohamed h

I tried that but it changes the color of all the boxes not just the red boxes for example?

Comment posted by Sangar Lal

oaky so now you need to pass the clicked index also can you please send your full that loop code i will tell that

Comment posted by Mohamed h

please send me your email for you send