an existent (pure) javascript function doesn't work with a new html element (created after that function):
document.querySelector('li').onmouseover = function() {
document.querySelector("li").innerHTML ="Hai soffermato il mouse qui!";
}
document.querySelector('li').onmouseout = function() {
document.querySelector("li").innerHTML ="Sofferma il mouse qui";
}
document.getElementById('bottone1').onclick = function() {
var Lista = document.getElementById('lista');
var NuovoElemento = document.createElement('li');
NuovoElemento.innerText = 'Nuova voce'; // innerHTML
Lista.insertBefore(NuovoElemento, Lista.lastChild);
}
<p><b>Elenco puntato:</b></p>
<ol id="lista">
<li>Sofferma il mouse qui</li>
</ol>
<button id="bottone1">Aggiungi voce</button>
It's right so (but not good, imho), I know. But, sorry, I don't understand this thread, that solves the problem (widthout explains it) :-( Javascript function doesn't work when creating a new HTML element
Thanks (more solito).