detect the widest cell w/ jQuery

前端 未结 5 928
挽巷
挽巷 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:15

    var w = 0;
    $("#myTable tr td:first").each(function(){
        if($(this).width() > w){
            w = $(this).width();
        }
    });
    

提交回复
热议问题