你走了:
$(document).ready( function() { // the following will select all 'td' elements with class "of_number_to_be_evaluated" // if the TD element has a '-', it will assign a 'red' class, and do the same for green. $("td.of_number_to_be_evaluated:contains('-')").addClass('red'); $("td.of_number_to_be_evaluated:contains('+')").addClass('green'); }
然后使用CSS来设置输入元素的样式:
td.red { color: red; } td.green { color: green; }