Friday, January 1, 2010

[jQuery] Re: trying to do Math.min on 3 tds by excluding if one = 0

This shoud do the job...

$("tr." + i).each(function() {
var ithis = $(this).find("td:lt(3)").map(function() {
if ($(this).html() === "0") {
return null;
} else {
return this;
}
}).min();
$(this).find("td.r1").empty().append(roundVal(ithis));
});

so, you select the first 3 cells, and then do the map function, which
is similar to each... for every selected cell, if its content is "0",
then "deselect" it... so after the map function, you only have those
cells that doesn't contain "0", on them you run min()....

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate