function add(e){
var container = document.getElementById('content');
var text = document.getElementById(e).innerHTML;
var newNode = document.createElement("span");
newNode.innerHTML = text;
container.appendChild(newNode);
var ui =document.getElementById(e);
ui.style.visibility="hidden";
// 加上这段就可以了
newNode.onclick = function(){
container.removeChild(this);
ui.style.visibility="visible";
}
}
绑定事件的兼容写法:
function addEvent(obj,e,fun){
obj.attachEvent ? obj.attachEvent("on"+e,fun) : obj.addEventListener(e,fun,false);
}
//为xxx绑定click事件
addEvent(xxx, "click", function(){
//....
});