detect the widest cell w/ jQuery

前端 未结 5 903
挽巷
挽巷 2021-01-19 21:34

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?

5条回答
  •  感情败类
    2021-01-19 22:24

    var widestTdLabel=0;
    $('#myTable td').each(function(index) { 
        if($(this).find('label').width()>widestTdLabel)
            widestTdLabel=$(this).find('label').width();
    });
    alert(' width of the widest label is:'+widestTdLabel);
    

提交回复
热议问题