Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div id="div0" draggable="true">this is a simple test</div>
  <div id="div1" style="width:200px;height:100px;background:green"></div>
  <script>
    var div0 = document.getElementById("div0");
    var div1 = document.getElementById("div1");
    div0.addEventListener("pointerdown", (e) => {
      div1.setPointerCapture(e.pointerId);
    }, false);
    div0.addEventListener("dragstart", (e) => {
      console.log(e.type);
      e.dataTransfer.setData("text", div0.innerHTML);
    }, false);
    div1.addEventListener("pointerdown", (e) => {
      div1.setPointerCapture(e.pointerId);
    }, false);
    div1.addEventListener("dragover", (e) => {
      e.preventDefault();
    }, false);
    div1.addEventListener("drop", (e) => {
      e.preventDefault();
      var data = e.dataTransfer.getData("text");
      div1.innerHTML = div1.innerHTML + " " + data;
    }, false);
    var pointer_events = ["pointerup", "pointerdown", "gotpointercapture",
                          "lostpointercapture", "pointermove"];
    pointer_events.forEach((element) => {
      div1.addEventListener(element, (e) => {
        console.log(e.type);
      }, false);              
    });
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
mingchoupro
0viewers