当一个元素被删除到另一个元素(称为cookiemonster)时,该代码应该使一个元素从列表中消失
addEvent(cookiemonster, 'drop', function (e) {
if (e.stopPropagation) e.stopPropagation();
var el = document.getElementById(e.dataTransfer.getData('text'));
el.parentNode.removeChild(el);
return false;
});
答案 0 :(得分:1)
像这样创建一个辅助变量
addEvent(cookiemonster, 'drop', function (e) {
if (e.stopPropagation) e.stopPropagation();
var el = document.getElementById(e.dataTransfer.getData('text'));
var aux = el.parentNode;
aux.removeChild(el);
return false;
});