I am 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 does not work, I looked through this whole site and Google and can not find a solution. I don't want to use jQuery for this (it's a small custom HTML5 script, so I don't need this huge library for one little thing), and even when I try to use the jQuery method, it still doesn't work.
source share