$$('.add').each(function(element){
element.onclick = function(){
$(this.title).firstChild.appendChild($(this.title).firstChild.firstChild);
}
});
$$('.add').each(function(element){
element.onclick = function(){
var tr = document.createElement("tr");
tr.innerHTML = $(this.title).firstChild.firstChild.innerHTML;
$(this.title).firstChild.appendChild(tr);
}
});
$$('.add').each(function(element){
element.onclick = function(){
var td = document.createElement("td");
td.innerHTML = $(this.title).firstChild.firstChild.firstChild.innerHTML;
var tr = document.createElement("tr");
tr.appendChild(td);
$(this.title).firstChild.appendChild(tr);
}
});
function deleteElement() {
if (Event.findElement(event, 'table').firstChild.childNodes.length == 2) return alert("请至少保留一条数据!");
Element.remove(Event.findElement(event, 'tr'));
}
这里面有些函数或者动作也许有些人没见到过,其实是prototype.js中的,我现在基本上都是在它的框架基础上写客户端脚本甚至服务端脚本的,感觉很舒服,效率也会高很多,特别是在精简代码方法。以后有机会会详细的介绍一下prototype框架。