【发布时间】:2014-09-04 01:28:59
【问题描述】:
<div id="wrapper" style="width:50px; overflow:hidden;">
<span id="innerPart" style="white-space: nowrap; width: auto;">Lorem ipsum...</span>
</div>
你好互联网,
我试图获得 innerPart 需要通过 JS 完全显示的宽度。
尝试使用document.getElementById("innerPart").width;,但它只是返回null
【问题讨论】:
-
尝试将
css:inline-block分配给该跨度并检查,如果您在尝试 dis 后没有获得宽度,请在此处评论 -
不工作。我意识到 '.getAttribute("width")' 是错误的函数。但是“.width”也是空的。
-
应该是
.css("width") -
我没有使用 jquery atm。我现在就试试。
-
很遗憾,它也不起作用。
标签: javascript html width