<html>
<head>
<script>
function mostra(){
alert(document.childNodes[0].nodeName);
}
window.onload=mostra;
</script>
</head>
<body>
</body>
</html>
...mi restituisce HTML.Questo significa che il figlio di document è HTML.
document ha un figlio solo, come dimostrato da questo codice:
<html>
<head>
<script>
function mostra(){
alert(document.childNodes.length);
}
window.onload=mostra;
</script>
</head>
<body>
</body>
</html>
...che restituisce 1.Quindi: document ha un solo figlio che è HTML.
Nessun commento:
Posta un commento