{"id":1705,"date":"2014-12-01T13:15:10","date_gmt":"2014-12-01T11:15:10","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=1705"},"modified":"2018-06-20T16:48:21","modified_gmt":"2018-06-20T13:48:21","slug":"html5-drag-and-drop-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/","title":{"rendered":"HTML5 Drag and Drop Example"},"content":{"rendered":"<p>Usability, an important part of web interface eases the way we communicate with web. Many new technologies and\u00a0functionalities are invented to ease the development effort as well as improve the overall way in which users interact with web. HTML5 has given many things as of today to improve the browser functionalities on client side with minimum amount of scripting. It\u00a0provides a great way to implement drag and drop functionality in modern browsers. We are going to see how it is implemented with a basic example of drag and drop in an image from one div to another.<\/p>\n<p>[ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;]<\/p>\n<p>To achieve drag and drop functionality with traditional HTML4, developers would have to use complex Javascript code. HTML 5 provides\u00a0a Drag and Drop API that brings support to the browser making it much easier to code up. No extra plugins needed to be installed. It is supported by the following major browsers:<\/p>\n<ol>\n<li>Internet Explorer 9+<\/li>\n<li>Firefox<\/li>\n<li>Opera, Chrome<\/li>\n<li>Safari<\/li>\n<\/ol>\n<p><strong>Note:<\/strong> Drag and drop does not work in Safari 5.1.7 and earlier versions.<\/p>\n<h2>1. Setting up two divs<\/h2>\n<p>We will first code two create two div boxes. One div will contain the image to be dragged. The other div will be the destination where the image needs to be dragged.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;style&gt;\r\n        #div1, #div2\r\n        {float:left; width:280px; height:180px; margin:10px;padding:10px;border:1px solid #aaaaaa;}\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;div id=&quot;div1&quot;&gt;\r\n &lt;img src=&quot;drag.png&quot; width=&quot;250&quot; height=&quot;150&quot; id=&quot;drag1&quot;&gt;\r\n&lt;\/div&gt;\r\n\r\n&lt;div id=&quot;div2&quot;&gt;&lt;\/div&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Output for above code is two div boxes with one div box containing our image<\/p>\n<figure id=\"attachment_1807\" aria-describedby=\"caption-attachment-1807\" style=\"width: 573px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/11.jpg\"><img decoding=\"async\" class=\"wp-image-1807 size-full\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/11.jpg\" alt=\"1 drag and drop\" width=\"573\" height=\"400\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/11.jpg 573w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/11-300x209.jpg 300w\" sizes=\"(max-width: 573px) 100vw, 573px\" \/><\/a><figcaption id=\"caption-attachment-1807\" class=\"wp-caption-text\">Initial divs<\/figcaption><\/figure>\n<h2>2. Make the elements draggable<\/h2>\n<p>Now, we need to first make the image draggable. Set the attribute <code>\"draggable = true\"<\/code><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;div id=&quot;div1&quot;&gt;\r\n&lt;img src=&quot;drag.png&quot; draggable=&quot;true&quot; width=&quot;250&quot; height=&quot;150&quot; id=&quot;drag1&quot;&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<h2>3. Set up events to handle drag functionality<\/h2>\n<p>Set the <code>ondragstart<\/code> event in the <code>img<\/code> tag to call <code>dragInitiliaze()<\/code> function as follows :<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;img src=&quot;drag.png&quot; draggable=&quot;true&quot; ondragstart=&quot;return dragInitialize(event)&quot; width=&quot;250&quot; height=&quot;150&quot; id=&quot;drag1&quot;&gt;\r\n<\/pre>\n<p>The <code>ondragstart<\/code> event in <code>img<\/code> tag detects when the drag is initialized\u00a0and then it calls the <code>dragInitiate()<\/code> function. The <code>dragInitiate()<\/code> function, then\u00a0catches the event. It sets the <code>effectAllowed<\/code> value to &#8220;move&#8221;\u00a0and has\u00a0<code>dataTransfer.setData()<\/code> method which sets the data type and the value of the dragged data.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n\r\n&lt;script type=&quot;text\/javascript&quot;&gt;\r\n\r\nfunction dragInitialize(ev) {\r\nev.dataTransfer.effectAllowed='move';\r\nev.dataTransfer.setData(&quot;Text&quot;, ev.target.getAttribute('id'));\r\nreturn true;\r\n}\r\n\r\n&lt;\/script&gt;\r\n\r\n&lt;!-- In body add the following draggable attributes to first div --&gt;\r\n\r\n&lt;div id=&quot;div1&quot; &gt;\r\n&lt;img src=&quot;drag.png&quot; draggable=&quot;true&quot; ondragstart=&quot;return dragInitialize(event)&quot; width=&quot;250&quot; height=&quot;150&quot; id=&quot;drag1&quot;&gt;\r\n&lt;\/div&gt;\r\n\r\n<\/pre>\n<figure id=\"attachment_1809\" aria-describedby=\"caption-attachment-1809\" style=\"width: 663px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/2.jpg\"><img decoding=\"async\" class=\"wp-image-1809 size-full\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/2.jpg\" alt=\"2 drag and drop\" width=\"663\" height=\"534\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/2.jpg 663w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/2-300x241.jpg 300w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><\/a><figcaption id=\"caption-attachment-1809\" class=\"wp-caption-text\">Dragging Image from one div to other<\/figcaption><\/figure>\n<h2>4. Completing the drop and putting it all together<\/h2>\n<p>By default, the elements that are set to be <code>draggable<\/code> cannot be dropped in any other elements. The drop functionality needs to be handled by events provided by Drag-and-Drop API. We have to take care of following things :<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n\r\nfunction allowDropStatus(ev) {\r\nev.preventDefault();\r\nreturn false;\r\n}\r\n\r\nfunction dropComplete(ev) {\r\nev.preventDefault();\r\nvar src = ev.dataTransfer.getData(&quot;Text&quot;);\r\nev.target.appendChild(document.getElementById(src));\r\nev.stopPropagation();\r\nreturn false;\r\n}\r\n\r\n&lt;!-- Modify the 2nd div to accept the drop --&gt;\r\n\r\n&lt;div id=&quot;div2&quot; ondrop=&quot;return dropComplete(event)&quot; ondragover=&quot;return allowDropStatus(event)&quot;&gt;&lt;\/div&gt;\r\n<\/pre>\n<ol>\n<li>\u00a0The div should listen to drop event so that it can accept the drop and place the image in its destination.<\/li>\n<li><code>ondragover<\/code> listener event is fired whenever a dragged image is over the destination div<\/li>\n<li><code>allowDropStatus()<\/code> prevents the default browser action so that we can code and handle the drop functionality.<\/li>\n<li><code>dropComplete()<\/code> function\u00a0does following three tasks :<\/li>\n<\/ol>\n<ul>\n<li>Prevents default browser action after the image has been dropped<\/li>\n<li>Fetches the data of image from <code>getData<\/code> which was stored while the image was selected for drag<\/li>\n<li>Appends the data to new div<\/li>\n<li>Stops the propagation of image<\/li>\n<\/ul>\n<p>If you observe carefully, we can drag the image from first div to second. But, what if we want to drag the image back to first div. The image is set to <code>draggable<\/code>, so it will be dragged. But, our first div is not set to handle drop. Let&#8217;s modify our first div so that it can handle the drop.<\/p>\n<p>We put following two listeners in first div to accept drop :<\/p>\n<ol>\n<li><code>ondragover<\/code> listener which calls\u00a0<code>allowDropStatus<\/code> function<\/li>\n<li><code>ondrop<\/code> \u00a0listener which calls\u00a0<code>dropComplete<\/code>\u00a0function<\/li>\n<\/ol>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n\r\n&lt;div id=&quot;div1&quot; ondrop=&quot;return dropComplete(event)&quot; ondragover=&quot;return allowDropStatus(event)&quot;&gt;\r\n&lt;img src=&quot;drag.png&quot; draggable=&quot;true&quot; ondragstart=&quot;return dragInitialize(event)&quot; width=&quot;250&quot; height=&quot;150&quot; id=&quot;drag1&quot;&gt;\r\n&lt;\/div&gt;\r\n\r\n<\/pre>\n<figure id=\"attachment_1810\" aria-describedby=\"caption-attachment-1810\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/3.jpg\"><img decoding=\"async\" class=\"wp-image-1810 size-full\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/3.jpg\" alt=\"3 drag and drop\" width=\"650\" height=\"478\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/3.jpg 650w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/3-300x220.jpg 300w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1810\" class=\"wp-caption-text\">Completing drop in second div<\/figcaption><\/figure>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/2.jpg\"><br \/>\n<\/a>This completes our simple example for Drag and Drop. It is totally based on handling of events and listeners which are provided by native HTML5 API<\/p>\n<h2>Conclusion and further applications<\/h2>\n<p>So, now we can drag \u00a0images back and forth efficiently. Drag and Drop functionality has numerous uses in improving the overall usability. Using the logic presented above and a glimpse of how various events of Drag-and-Drop API can be used, you can extend them to use and apply for any other functionality. As with any technology, HTML 5 Drag-and-Drop API has its own advantages and disadvantages. Its upto you too whether use it or not.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here : <a title=\"HTML 5 Drag and Drop\" href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/11\/DragAndDrop.zip\"><strong>HTML 5 Drag and Drop<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Usability, an important part of web interface eases the way we communicate with web. Many new technologies and\u00a0functionalities are invented to ease the development effort as well as improve the overall way in which users interact with web. HTML5 has given many things as of today to improve the browser functionalities on client side with &hellip;<\/p>\n","protected":false},"author":32,"featured_media":914,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[59],"class_list":["post-1705","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html5","tag-drag-and-drop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>HTML5 Drag and Drop Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn more about drag and drop? Then check out our Example on how it is implemented with a drag and drop in an image from one div to another!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML5 Drag and Drop Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about drag and drop? Then check out our Example on how it is implemented with a drag and drop in an image from one div to another!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-01T11:15:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-06-20T13:48:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Viraj Khatavkar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Viraj Khatavkar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/\"},\"author\":{\"name\":\"Viraj Khatavkar\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/fdf1fff18ce41b5afa272af1e2590dda\"},\"headline\":\"HTML5 Drag and Drop Example\",\"datePublished\":\"2014-12-01T11:15:10+00:00\",\"dateModified\":\"2018-06-20T13:48:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/\"},\"wordCount\":1026,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"keywords\":[\"drag-and-drop\"],\"articleSection\":[\"HTML5\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/\",\"name\":\"HTML5 Drag and Drop Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"datePublished\":\"2014-12-01T11:15:10+00:00\",\"dateModified\":\"2018-06-20T13:48:21+00:00\",\"description\":\"Interested to learn more about drag and drop? Then check out our Example on how it is implemented with a drag and drop in an image from one div to another!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"HTML5\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/html5\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"HTML5 Drag and Drop Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/fdf1fff18ce41b5afa272af1e2590dda\",\"name\":\"Viraj Khatavkar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b7128884081cee0e56ad1db74315b792ddda53451beaa2669bcef6b6c9d2553?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b7128884081cee0e56ad1db74315b792ddda53451beaa2669bcef6b6c9d2553?s=96&d=mm&r=g\",\"caption\":\"Viraj Khatavkar\"},\"description\":\"Viraj has graduated from University of Mumbai, the financial heart of INDIA. Being a web geek &amp; having entrepreneurship in DNA; happens to be the Co-Founder of Tantra-Gyan (I) Business Solutions, heading Technology space. He loves PHP to the core and is great enthusiast for mastering the same. He prefers designing architectural planning of an application and researching new architectural solutions. He has developed various solutions logical as well as architectural for service industry web ERPs and Scraping apps. He is fascinated about SOA, web services and believes \\\"Good design increases software life and your leisure time as well :)\\\" Loves spending time for creating solutions for the betterment of society namely focusing on Education, Employment &amp; Civic Rights. Buzz him any moment, if you feel like; he would love to hear from you.\",\"sameAs\":[\"http:\/\/www.webcodegeeks.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/viraj-khatavkar\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HTML5 Drag and Drop Example - Web Code Geeks - 2026","description":"Interested to learn more about drag and drop? Then check out our Example on how it is implemented with a drag and drop in an image from one div to another!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/","og_locale":"en_US","og_type":"article","og_title":"HTML5 Drag and Drop Example - Web Code Geeks - 2026","og_description":"Interested to learn more about drag and drop? Then check out our Example on how it is implemented with a drag and drop in an image from one div to another!","og_url":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2014-12-01T11:15:10+00:00","article_modified_time":"2018-06-20T13:48:21+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","type":"image\/jpeg"}],"author":"Viraj Khatavkar","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Viraj Khatavkar","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/"},"author":{"name":"Viraj Khatavkar","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/fdf1fff18ce41b5afa272af1e2590dda"},"headline":"HTML5 Drag and Drop Example","datePublished":"2014-12-01T11:15:10+00:00","dateModified":"2018-06-20T13:48:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/"},"wordCount":1026,"commentCount":4,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","keywords":["drag-and-drop"],"articleSection":["HTML5"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/","url":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/","name":"HTML5 Drag and Drop Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","datePublished":"2014-12-01T11:15:10+00:00","dateModified":"2018-06-20T13:48:21+00:00","description":"Interested to learn more about drag and drop? Then check out our Example on how it is implemented with a drag and drop in an image from one div to another!","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-drag-and-drop-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"HTML5","item":"https:\/\/www.webcodegeeks.com\/category\/html5\/"},{"@type":"ListItem","position":3,"name":"HTML5 Drag and Drop Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/fdf1fff18ce41b5afa272af1e2590dda","name":"Viraj Khatavkar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4b7128884081cee0e56ad1db74315b792ddda53451beaa2669bcef6b6c9d2553?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b7128884081cee0e56ad1db74315b792ddda53451beaa2669bcef6b6c9d2553?s=96&d=mm&r=g","caption":"Viraj Khatavkar"},"description":"Viraj has graduated from University of Mumbai, the financial heart of INDIA. Being a web geek &amp; having entrepreneurship in DNA; happens to be the Co-Founder of Tantra-Gyan (I) Business Solutions, heading Technology space. He loves PHP to the core and is great enthusiast for mastering the same. He prefers designing architectural planning of an application and researching new architectural solutions. He has developed various solutions logical as well as architectural for service industry web ERPs and Scraping apps. He is fascinated about SOA, web services and believes \"Good design increases software life and your leisure time as well :)\" Loves spending time for creating solutions for the betterment of society namely focusing on Education, Employment &amp; Civic Rights. Buzz him any moment, if you feel like; he would love to hear from you.","sameAs":["http:\/\/www.webcodegeeks.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/viraj-khatavkar\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/1705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=1705"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/1705\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/914"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=1705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=1705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=1705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}