APRESTOUS
asked on
Find minimum value with jQuery
I have a table with all cells having unique id as "td_1", "td_2" etc.
I want to find which cell contains minimal value (content of cells are integers or "---" )
I use jQuery, so probably the solution will use it as well.
I want to find which cell contains minimal value (content of cells are integers or "---" )
I use jQuery, so probably the solution will use it as well.
ASKER
Hello,
thank you for very quick answer.
You solution find the minimum value.
But I need to know actually which cell contains this value.
thank you for very quick answer.
You solution find the minimum value.
But I need to know actually which cell contains this value.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you!
It works.
Only one remark.
If I use it so I get always min. value = 0.
But I changed second string into
var minValue = 999999999;
and it returns exactly what I meant.
It works.
Only one remark.
If I use it so I get always min. value = 0.
But I changed second string into
var minValue = 999999999;
and it returns exactly what I meant.
ohh...thanks for the tip and points
var minValue = 0;
$("td[id^='td_']").each(fu
var val = $(this).html();
if ( val != "---" )
{
val = parseInt( val );
if ( val < minValue )
{
minValue = val;
}
if ( val > maxValue )
{
maxValue = val;
}
}
});
alert("min value is: " + minValue );
alert("max value is: " + maxValue );