this.owner.appendChild(this.span); } function EditableText.prototype.onEditClick(){ event.cancelBubble = true; } function EditableText.prototype.onEditBlur(){ event.cancelBubble = true; var self = this.obj; self.span.innerHTML = ""; self.span.innerText = self.edit.value; } function EditableText.prototype.onSpanClick(){ event.cancelBubble = true; var self = this.obj; self.edit.value = this.innerText; this.innerHTML = ""; this.appendChild(self.edit); self.edit.focus(); }
function init(){ for(var i=0;i<20;i++){ new EditableText(document.body); var br = document.createElement("br"); document.body.appendChild(br); } } init(); </script>