[Javascript] Getting the width property of div

Alan Gardner gardner.alan at gmail.com
Tue Apr 5 10:03:37 CDT 2005


Can someone help me, I'm having trouble getting the width of a div
tag. I thought this would be a fairly easy syntactically, but all I
get is an empty string.

my CSS:
#div1 { width:400px };

my JS:
function getWidth() {
	alert(document.getElementById('div1').style.width);
}

How do I find out the current width of a div?
THA
Alan



More information about the Javascript mailing list