+ 1
Please, explain me every part of this code cause I am a beginner!!
code- <!DOCTYPE HTML> <html> <head> <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="box" ondrop="drop(event)" ondragover="allowDrop(event)" style="border:1px solid black; width:200px; height:200px"></div> <img id="image" src="sample.jpg" draggable="true" ondragstart="drag(event)" width="150" height="50" alt="" /> </body> </html>
1 ответ
0
A very easy and good explanation is already provided by the sololearn in Html 5 drag and drop section without connecting it to JavaScript. Read it carefully!
But for core understanding I recommend you to learn the basics of JavaScript.
P.S. I am a beginner as well but I understood the explanation given by sololearn without any basics of JavaScript.