user3282734
user3282734

Reputation: 21

How to measure table row height in pixels

Using Javascript, how to get table row height in actual pixels? In the example, I would like to get measurement from top of green border to the top of the next green border.

Using jQuery .height(), outerHeight(), .offsetHeight and .clientHeight does not return correct answer (it's 44px). (see http://jsfiddle.net/kaG7g/8/ )

HTML

<table>
    <tr><td>this a table</td></tr>
    <tr><td>this is a contents</td></tr>
    <tr id="tableElement"><td>of element</td></tr>
</table>

CSS

td {
    height:20px;
    border-top:10px solid green;
    border-bottom:10px solid yellow;
}

Upvotes: 2

Views: 3759

Answers (3)

Sandy
Sandy

Reputation: 817

Use This

var height = $('#table').height();    

Upvotes: 0

dhana
dhana

Reputation: 6525

Try this,

Demo

console.log( $('td').css('border-top').split('p')[0] );
console.log( $('td').css('border-bottom').split('p')[0] );
console.log( $('td').height() );

Upvotes: 2

angfreak
angfreak

Reputation: 1003

you can use following code..

$("#table tr").height()

Upvotes: 0

Related Questions