开发者

Get width of element with no css or width attribute

Scenario: You have a div with some text, this div has no css width, no jquery width, no width attribute assigned to it in any way. However it has a width due to the content that is inside it, this is undefined, repo开发者_StackOverflow社区rts as "null" in jQuery. My question is: is there any way to retireve the width of this div?


$(element).width() should give you the actual width. With $(element).outerWidth(includeMargin) you can even get the width including padding, border, and, if desired, the margin.


with jquery you can do below

$('#id').width()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜