Sunday 15 January 2012

colors - Colorize negative/positive numbers (jQuery) -


I want to color the numbers in a table for better readability:

  • green positive (+00.00);
  • Red for negative (-00.00) and;
  • Black for default case (no sign)

Here then go:

  $ (document) .ready (function () {// The following "td" elements are selected "class_number_to_be_evaluated" // If the '-' in the TD element, Red 'class and also for green color. $ ("Td.of_number_to_be_evaluated: in (' - ')". AddClass (' red '); $ ("td.of_number_to_be_evaluated:" (' + ') ) AddClass ('green');}  

Then use CSS in the input elements in style:

  td.red {color: red; } Td.green {color: green;}  

No comments:

Post a Comment