简体   繁体   中英

how i can know the width of div element

如何获取JavaScript中HTML <div>元素的宽度(以像素为单位)?

try divElement.offsetWidth || divElement.clientWidth divElement.offsetWidth || divElement.clientWidth

and also you might as well want to try divElement.style.width

Note: divElement is the DOM element of your div which can be obtained by document.getElementById("yourDivId")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM