
Originally Posted by
inderjeetsinghsethi
document.getelementbyid('test')
is not a function. I think you want:
Code:
document.getElementById('test')
Anyways, this works just fine:
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function findwidth(){
var width = document.getElementById('test').offsetWidth;
alert(width);
}
</script>
</head>
<body onload="findwidth();">
<div style="width:965px">
<div style="width:100%" align="center">
<div style="width:365px" align="center">
<div id="test">
</div>
</div>
</div>
</div>
</body>
</html>
Bookmarks