I have a table with different values. First column contains labels. I need to get the width of the widest label. I assume I need some sort of a loop, but then what?
This should work - it will go through each of the tds (in myTable) and find the widest:
var widest = 0;
$("#myTable tr td:first").each(function()
{
widest = ($(this).width() > widest) : $(this).width() : widest;
});
alternatively:
var widest = 0;
$("#myTable tr td:first").each(function()
{
if($(this).width() > widest){
widest = $(this).width()
}
});