Ciao a tutti, vorrei una chiarificazione per quanto riguarda l'HTML dom e in particolare il metodo
document.anchors.
In un linguaggio del tipo seguente:
codice:
<!DOCTYPE html>
<html>
<head>
<script>
function f()
{
var x=document.anchors[0];
var y=document.getElementById("P1");
y.innerHTML=x;
}
</script>
</head>
<body>
<p id="P1">
</p>
<button onclick="f()">
Clicca
</button>
<br>
<a name="A1">
Ancora 1
</a>
</body>
</html>
perché quando clicco il button, il metodo document.anchors[0] non mi restituisce l'àncora?
Cioè perché nel testo del nodo p non appare object node element?
Inoltre se mettessi l'attributo href nel tag a, allora nel testo del nodo p apparirebbe il valore dell'href.
Grazie.