HTML 5 how to drag and drop

Let us add Drag and Drop event  using HTML5.

  • Drag and drop is a very common feature. It is when you “grab” an object and drag it to a different location.
  • In HTML5, drag and drop is part of the standard, and any element can be draggable.

Below is the code for html file.


function allowDrop(ev)

function drag(ev)

function drop(ev)
var data=ev.dataTransfer.getData(“Text”);;

<link href=”scro.css” rel=”stylesheet” type=”text/css”>

<img id=”drag1″ src=”dre.png” draggable=”true” ondragstart=”drag(event)” width=”356″ height=”89″>



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s