How to use drag and drop events in HTML5
This article mainly introduces how to use drag-and-drop events in HTML5. It is very detailed and has certain reference value. Friends who are interested must finish reading it.
Browser support
Internet Explorer 9, Firefox, Opera 12, Chrome, and Safari 5 support drag and drop.
Note: drag and drop is not supported in Safari 5.1.2.
HTML5 drag and drop instance
# div1 {width:488px;height:70px;padding:10px;border:1px solid # aaaaaa;} 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));}
Please drag and drop the picture of Aseoe logo into the rectangle: P > div >