Created
July 2, 2015 07:27
-
-
Save karkranikhil/be3e0989809ba4c57a7a to your computer and use it in GitHub Desktop.
drag and drop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE HTML> | |
| <html> | |
| <head> | |
| <style> | |
| #div1, #div2 | |
| {float:left; width:100px; height:35px; margin:10px;padding:10px;border:1px solid #aaaaaa;} | |
| .divScroll { | |
| overflow:scroll; | |
| height:200px; | |
| width:100px; | |
| } | |
| </style> | |
| <script> | |
| function allowDrop(ev) { | |
| ev.preventDefault(); | |
| } | |
| function drag(ev) { | |
| ev.dataTransfer.setData("text", ev.target.id); | |
| } | |
| function drop(ev) { | |
| ev.preventDefault(); | |
| var data = ev.dataTransfer.getData("text"); | |
| ev.target.appendChild(document.getElementById(data)); | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <div id="div1" class="divScroll" ondrop="drop(event)" ondragover="allowDrop(event)"> | |
| <img src="infylogo.png" draggable="true" ondragstart="drag(event)" id="drag1" width="88" height="31"> | |
| </div> | |
| <div id="div2" class="divScroll" ondrop="drop(event)" ondragover="allowDrop(event)"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment