008.xhtml (883B)
1 <?xml version="1.0" encoding="utf-8"?> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>Removing div element during drag and drop with text/uri-list data</title> 5 <style type="text/css"> 6 div 7 {width:40px; 8 height:40px; 9 margin-top:20px; 10 padding:40px; 11 color:white; 12 background-color:gray;} 13 p + div 14 {background-color:navy;} 15 </style> 16 </head> 17 <body> 18 <div 19 draggable="true" 20 ondragstart="event.dataTransfer.effectAllowed = 'copy';event.dataTransfer.setData('text/uri-list','data:text/plain,PASS');document.querySelector('body').removeChild(document.querySelector('div'))" 21 /> 22 <p>Drag gray box above to the navy box below and drop it. You should see word PASS once you drop it.</p> 23 <div 24 ondragover="return false" 25 ondrop="document.querySelector('div').appendChild(document.createTextNode(event.dataTransfer.getData('text/uri-list').substr(16,4)))" 26 /> 27 </body> 28 </html>