<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Pagina senza titolo</title>
<script language="javascript" type="text/javascript">
// <!CDATA[
window.onload = function()
{
window.setTimeout(scrivi_su_paragrafo, 5000);
};
function scrivi_su_paragrafo()
{
$("paragrafo").innerHTML = 'Buon giorno JavaScript';
}
//al posto di mettere document.getElementById("div1"), mettere $("div1")
//da prototype.js
function $()
{
var elements = new Array();
for (var i = 0; i < arguments.length; i++)
{
var element = arguments[i];
if (typeof element == 'string')
element = document.getElementById(element);
if (arguments.length == 1)
return element;
elements.push(element);
}
return elements;
}
// ]]>
</script>
</head>
<body>
<p id="paragrafo">Tra 5 secondi questo testo sarà cambiato</p>
</body>
</html>
--------------------------------------
Già ma a questo punto trovo difficoltà a comprendere la funzione $()