Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get real width td table

I create one table in html and this table width is 988 px and tr width is 100% table width.

In table tag exist 5 td tag that this td tag width 20%.

When I get with these tags with jQuery (td tag) show me in console this :

198 
197 
198 
197 
198

but I see this tags width in console 197.59.

I want get this value not these 197 or 198.

like image 901
brad Avatar asked Jul 24 '13 15:07

brad


1 Answers

More precise than element.offsetWidth is:

element.getBoundingClientRect().width

it shows exact width as rendered by the browser.

MDN reference: getBoundingClientRect

like image 66
Dziad Borowy Avatar answered Oct 04 '22 23:10

Dziad Borowy