Skip to content
Advertisement

Text color change in the table [closed]

JavaScript

I want to change the color of the text in a td element in html.

It works while loading the page, but after the page is loaded the style does not work.

How can I get it working?

Advertisement

Answer

First, you would encapsulate the logic that decides which css class to apply to the element based on the birthday inside a function makeTdClass:

JavaScript

With such a function, you would pass in the date parameter and it would return the appropiated css class, wich you might define on a tag on in a separated .css file:

JavaScript

Finally, you would be able to call this function from within your PHP file and put the returned value as the class attribute of your elements:

JavaScript

You can use the short way for inserting php content:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement