how to get width of div in js code example Example: javascript get width of a div document.getElementById("mydiv").offsetWidth