005.xhtml (814B)
1 <?xml version="1.0" encoding="utf-8"?> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>Removing span element during drag and drop of selection</title> 5 <style type="text/css"> 6 div 7 {min-height:100px; 8 width:100px; 9 padding:20px; 10 color:white; 11 background-color:navy;} 12 </style> 13 </head> 14 <body onload="window.getSelection().selectAllChildren(document.querySelector('span'))"> 15 <p><span ondragstart="document.querySelector('p').removeChild(document.querySelector('span'))">Drag me</span></p> 16 <p>Drag selection above to the navy box below and drop it. You should see word PASS once you drop it in the box.</p> 17 <div ondragover="return false" ondrop="document.querySelector('div').appendChild(document.createTextNode((event.dataTransfer.getData('text/plain') == 'Drag me')?'PASS':'FAIL'))"/> 18 </body> 19 </html>