根据div / table中的某些字符应用CSS [关闭]

I have a php function that pulls my csv data and display it as a table on a web page, something very simple!

My question is, is it possible to have a php code or javascript that scans my table td and if the td ends in a certain character/flag/word, then apply a certain CSS to that td?

I want this so I can apply different css images and colors to my td's depending on the character at the end!

This is javascript solution based on last character and test only for two variations, basically it takes last character from table cell text content and checks it against another character. For more options I would use switch.

http://jsfiddle.net/xqKvp/

You can change css classes with className property instead of changing inline styles.

element.className = 'myClass';

There are also numerous options for checking with regular expressions methods or other string object methods, depending on your needs.