Javascript width of div, returns 0
Try document.getElementById("mydiv").offsetWidth
instead of .style.width
Use this instead:
document.getElementById("areaDraw").offsetWidth
Edit: As requested, an explanation of why this works (just as an extra reference).
It's because the property style.width
is the width as defined explicitly in the CSS, wheareas offsetWidth
finds the actual width of the element as it's displayed in the browser.