Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想要动态宽度元素(宽度:auto)的数字宽度(不带 Px),我用 clientWidth、parseInt、offsetWidth 尝试了它,但它总是以“0”或 NaN 返回。
我怎么能有这些数字?
非常感谢提前。
在jQuery中
alert($("#mydiv").innerWidth().replace("px",""));
在javascript中
alert (document.getElementById('mydiv').style.width.replace("px",""));