我想要的颜色,以根据病情红色负值颜色在TD值的情况下,我现在所做的是这样的:想使用jQuery
$('td.numeric:contains('-')").addClass("negative")
以上具有类名称的数字,如果代码中找到TD值包含' - ',它将类'负'应用于该td。
我的问题是,如果我应用数字类例如日期值也包含' - '作为分隔符,并使日期颜色为红色。
所以我的问题是,我怎么才能找到td值startwith' - '?
像
$('td.numeric:startwith('-')").addClass("negative")
CSS
.numeric { text-align:right; }
.negative { text-align:right; color:red; }
这解决了你的问题:http://stackoverflow.com/questions/1824266/colorize-negative-positive-numbers-jquery – senthilbp
有没有任何内置函数startwith没有正则表达式? –
你不能在日期td上放一个类,只是使用'.not()'排除它们吗? – charlietfl