javascript - When using H5 drag and drop, why is the dragged element removed?
ringa_lee
ringa_lee 2017-06-22 11:53:56
0
1
963

1. Please see the phenomenon:
https://codepen.io/xuyu/proje...

2. The effect I want to achieve is to copy the dragged element to the specified area without deleting the dragged element.

ringa_lee
ringa_lee

ringa_lee

reply all(1)
阿神

document.addEventListener("drop", function( event ) {

  // prevent default action (open as link for some elements)
  event.preventDefault();
  // move dragged elem to the selected drop target
  if ( event.target.className == "landingArea" ) {
      event.target.style.background = "";
      //dragged.parentNode.removeChild( dragged );
      $(event.target).append($(dragged).clone().css('opacity', 1))
  }

}, false);

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template