Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the height of a table row

How can I calculate the height of a row (in pixels) in a table with JavaScript?

<table>
  <tr>
    <td>Cell 1</td>
    <td>Cell 2</td>
  </tr>
</table>
like image 571
user495688 Avatar asked Nov 22 '10 07:11

user495688


People also ask

How do I find the height of a row in a table?

var trTagHeight = tableHeight/totalRowInTable; console. log(trTagHeight); //Note: This is approx value of each row, excluding padding and cell padding value. This is probably the closest answer so far. The only thing is that it won't guarantee any particular row... just the average height of all of them.

How do you fix the height of a row in a table?

Change column and row height To change the height, do one of the following: To make all rows in the table the same height, select Layout > Distribute Rows. To make all the columns in the table the same height, select Layout > Distribute Columns. Note: In Excel, select Home > Format, and then select Row Height.

Why can't I change the height of a row in a table?

From the Table menu, select “Table Properties.” Click on the Table tab, then the Options button. Uncheck “Automatically resize to fit contents.” Click “OK.” Now click on the “Row” tab in Table Properties. Make sure that “Specify Height” is checked and the size in the middle box is the height you want your rows to be.

How do I set the height and width of a row in HTML?

To set the cell width and height, use the CSS style. The height and width attribute of the <td> cell isn't supported in HTML5. Use the CSS property width and height to set the width and height of the cell respectively.


1 Answers

function findHeights() {
            var tbl = document.getElementById('your table').rows;
            alert(tbl[0].offsetHeight); // row 1
}
like image 194
Tim Avatar answered Sep 26 '22 06:09

Tim