XHTML should almost never be used. The language attribute for the script tag has been deprecated. The childNodes need not be used* since a more convenient object exists - getElementsByTagName('div'):
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function getIds(par){
par = document.getElementById(par).getElementsByTagName('div');
for(var a = [], i = 0; i < par.length; ++i)
a.push(par[i].id || 'has no ID');
alert(a.join('\n'));
};
</script>
</head>
<body>
<div>
<div id = "parent_id">
<div id = "inner_div_19"></div>
<div id = "inner_div_210"></div>
<div id = "inner_div_11"></div>
<div id = "inner_div_99"></div>
</div>
<input type="button" onclick="getIds('parent_id');" value="Get Id's">
</div>
</body>
</html>
* The childNodes will not pick up nested divisions within the nested divisions though, so depending upon how deep one wants to probe, may be preferred.
Bookmarks