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