Ciao!
Ho scritto questo semplice e breve codice:
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>esercizio</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="./js/prototype.js"></script>
<script type="text/javascript">
var ESE = Class.create();
ESE.prototype = {
initialize: function (element) {
this.addObservers(element);
},
addObservers: function(element) {
Event.observe(element, "click", this.addButton.bind(this));
},
addButton : function (event) {
var elt = Event.element(event);
var f = new Element("form");
var b = new Element("button");
elt.update();
elt.insert(f);
f.insert(b);
b.innerHTML = "OK";
}
};
var esercizio = function () {
var es = new ESE($('prova'));
}
document.observe("dom:loaded", esercizio);
</script>
</head>
<body>
<div id="prova"> CLICCA QUI </div>
</body>
</html>
Se clicco su "CLICCA QUI" appare correttamente il bottone "OK".
Se clicco sul bottone "OK", il bottone scompare. Coma mai? Come faccio a fare in modo che non scompaia?
Grazie!!!