jQuery outerWidth on a parent element which has child elements with padding

霸气de小男生 提交于 2019-12-13 19:57:47

问题


I have a slight issue, i am trying to get the outer width of a table cell. The table cell has some inputs as child elements, in this case a textbox and an image.

The width of the image is 16px and the width on the textbox is 115px. The textbox also has padding left and right, both 2px (equals 4px).

I would assume that td.outerWidth() gives me 119 + 16 = 135px (115 + 4 padding + 16) but instead it gives me 115 + 16 = 131px.

Outer width do return the correct width on all child elements separatly but there seems to be problems when calculating the outer width on a parent element which has child elements with padding. If i remove the padding, then everything works fine.

Does anyone else have this problem or any solution to it?

来源:https://stackoverflow.com/questions/4194138/jquery-outerwidth-on-a-parent-element-which-has-child-elements-with-padding

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!