document.getElementById('demo').innerHTML




<!DOCTYPE html>
<html>
<body>

<button onclick="document.getElementById('demo').innerHTML=Date()">The time is?</button>

<p id="demo"></p>

</body>
</html>

***************************************************

Nell'esempio sopra, il codice JavaScript modifica il contenuto dell'elemento con id = "demo".

Nell'esempio successivo, il codice modifica il contenuto del proprio elemento (utilizzando this.innerHTML):

Esempio
<!DOCTYPE html>
<html>
<body>

<button onclick="this.innerHTML=Date()">The time is?</button>

</body>
</html>

*********************************************************
Il codice JavaScript e' spesso lungo diverse righe. È piu' comune vedere gli attributi degli eventi che chiamano funzioni:
<!DOCTYPE html>
<html>
<body>

<p>Click the button to display the date.</p>

<button onclick="displayDate()">The time is?</button>

<script>
function displayDate() {
document.getElementById("demo").innerHTML = Date();
}
</script>

<p id="demo"></p>

</body>
</html>










( documentgetelementbyid'demo'innerhtml.html )- by Paolo Puglisi - Modifica del 17/12/2023