<table class="tb_list"></table>
$(function(){
$(".tb_list td").each(function(i,n){
var text = $.trim($(n).text());
var fVal = parseFloat(text);
if(!isNaN(fVal) && fVal < ){
$(n).css("color","red");
}
});
});
2 当td里面有两个值时(示例中分隔符为<br>),代码如下
$(function () {
$(".tb_list td").each(function (i, n) {
//var txt = $.trim($(n).text());
var txt = $(n).html();
var arr = [];
try{
arr = txt.split("<br>");
}catch(e){}
var innTxt = "";
if(arr.length == ){
if (parseFloat(arr[]) < || parseFloat(arr[]) < ) {
if (parseFloat(arr[]) < ) {
innTxt += "<font color='red'>" + arr[] + "</font>";
}
else innTxt += arr[];
if (parseFloat(arr[]) < ) {
innTxt += "<br><font color='red'>" + arr[] + "</font>";
}
else innTxt += "<br>" + arr[];
$(n).html(innTxt);
}
}
});
});