I'm trying to read the width of a div without jQuery. The code I'm using is:
JS:
var windowwidth = parseInt(document.getElementById("window").style.width);
window.onload = function start() {
alert(windowwidth);
}
HTML:
<div id="window">
<p>Lorem ipsum dolor sit amet.</p>
</div>
CSS:
#window {
height: 250px;
margin: 0 auto;
width: 600px;
}
I don't understand why this isn't working, I've looked all over this site and google and can't figure out a solution. I don't want to use jQuery for this (it's a small custom HTML5 script so I don't need that huge library for one little thing) and even when I try the jQuery method, it still doesn't work.