Supriya Pandey Supriya Pandey - 1 year ago 37
CSS Question

Add a css class on td of table according to TD less or more value

I have a table in html with two td content in it. it is a dynamic td.I want to implement the functionality like if in each of table row, each big td value text color displayed as green and less value text display as red;

please find my source code:

if(forAsking<forProduction){"Less value");
//-----here I want to display Whatever value is less it displayed as red and other is green
//---same manner followed in there as well"More Asking");


Create 2 classes for those colors



Then first compare the values then append the result.



                   forData+='<td class="green">'+forProduction+'</td><td class="red">'+forAsking+'</td>';


                    forData+='<td class="green">'+forAsking+'</td><td class="red">'+forProduction+'</td>';

forData+= '</tr>';


You can see the demo here