内容をドラッグしてゴミ箱に捨てる
2095 ワード
drag
![](img/back.png)
//
var boxs = document.querySelectorAll(".box2");
//
var target = document.querySelector(".box1");
var img = document.querySelector("img");
//7
//
var dragEle = null;
for(var i=0;i<boxs.length;i++){
var box2 = boxs[i];
box2.ondragstart = function(e){
console.log(1," ");
e.dataTransfer.effectAllowed = "move";
e.dataTransfer.setData("className",e.target.className);
e.dataTransfer.setDragImage(img,10,10);
dragEle = e.target;
}
}
target.ondragover = function(e){
console.log(6," ");
e.preventDefault();
e.dataTransfer.dropEffect = "move";
}
target.ondrop = function(e){
console.log(7," ");
var eclassName = e.dataTransfer.getData("className");
var content = document.querySelector(".content");
content.removeChild(dragEle);
}