javascript - How to get the exact width of an inline element that has no width set?
PHP中文网
PHP中文网 2017-05-19 10:46:37
0
3
718

For example:

td has the width set, span has no width set.

1. Use $.width() to get the integer width, $('td').width() to get the 218px, span is 129px
2. Use clientWidth to get the width without margins and boder , span width is 0, td width is '218'
3. Use getComputedStyle to get final width , accurate to the decimal point , but the width of span obtained is auto, td is 217.5

question:

How to get the exact width of an element with no width set (accurate to the decimal point, displayed in px units)?

PHP中文网
PHP中文网

认证高级PHP讲师

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!