Advertisement
pgerman

HTML Scratchpad

Sep 16th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <style>
  5. #div1 {width:350px;height:70px;padding:10px;border:1px solid #aaaaaa;}
  6. </style>
  7. <script>
  8. function allowDrop(ev) {
  9. ev.preventDefault();
  10. }
  11.  
  12. function drag(ev) {
  13. ev.dataTransfer.setData("text", ev.target.id);
  14. //document.getElementById(ev.target.id).style.visibility='hidden';
  15. }
  16.  
  17. function drop(ev) {
  18. ev.preventDefault();
  19. var data = ev.dataTransfer.getData("text");
  20. ev.target.appendChild(document.getElementById(data));
  21. }
  22. </script>
  23. </head>
  24. <body>
  25.  
  26. <p>Drag the W3Schools image into the rectangle:</p>
  27.  
  28. <div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
  29. <br>
  30. <img id="drag1" src="img_logo.gif" draggable="true" ondragstart="drag(event)" width="336" height="69">
  31.  
  32. </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement