1

这段代码应该使一个元素在被放到另一个元素上时从列表中消失(称为 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;
});
4

1 回答 1

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;
});
于 2014-03-26T23:56:31.173 回答