get width of element by id javascript code example Example: javascript get width of a div document.getElementById("mydiv").offsetWidth