简体   繁体   中英

Get width of each column cell of first row of a table using jquery

I have a table lets suppose any random table. Now i need to get width of a every cell of a column of the first row of the table. Values has to be stored in an array.

Here you go with a solution.

I would request you to post your code for better understanding.

 var width_details = []; $('tr:nth-child(1) > td').each(function(){ width_details.push($(this).width()); }); console.log(width_details.sort(function(a, b){return ab}));
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table> <tbody> <tr> <td>342342342</td> <td>aa</td> <td>safsdertert34543543534</td> </tr> <tr> <td>Second Row</td> <td>asadasdasdasdsadadasdasasda</td> <td>ee</td> </tr> </tbody> </table>

Hope this will help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM