{"id":6735,"date":"2015-09-08T12:15:04","date_gmt":"2015-09-08T09:15:04","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=6735"},"modified":"2017-12-21T16:40:04","modified_gmt":"2017-12-21T14:40:04","slug":"jquery-drag-drop-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/","title":{"rendered":"jQuery Drag and Drop Example"},"content":{"rendered":"<p>The aim of this example is to explain and use drag and drop functionality with jQuery. Basically, in jQuery you can enable draggable functionality on any DOM element and move the draggable object by clicking on it with the mouse and dragging it anywhere within the viewport. Dragging and dropping can be a very intuitive way for users to interact with your site or web app. People often use drag-and-drop for things like:<\/p>\n<p>\u2022&nbsp;Moving email messages into folders<br \/>\n\u2022&nbsp;Reordering lists of items<br \/>\n\u2022&nbsp;Moving objects in games around, such as cards and puzzle pieces<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;qGGDqWnle19VavkM&#8217;]<\/p>\n<h2>1. Basic Setup &amp; Application<\/h2>\n<p>To begin, create and new HTML document and add the following basic syntax inside:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=\"utf-8\"&gt;\r\n\t&lt;title&gt;jQuery Drag &amp; Drop Example&lt;\/title&gt;\r\n\r\n    &lt;!-- LINKS SECTION  --&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"jquery-ui.css\"&gt;\r\n    &lt;script src=\"jquery-1.11.3.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"jquery-ui.js\"&gt;&lt;\/script&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;!-- STYLE SECTION --&gt;\r\n&lt;style type=\"text\/css\"&gt;\r\n\r\n&lt;\/style&gt;\r\n\r\n&lt;!-- HTML SECTION  --&gt;\r\n\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n\r\n&lt;\/script&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Don&#8217;t worry about the link files, you&#8217;ll find them attached in your final source download at the end of the article.<\/p>\n<p>Now let&#8217;s see a basic drag and drop example. First, create a new element in the HTML section and give it a class name.<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION  --&gt;\r\n&lt;div class=\"dragme\"&gt;Drag me!&lt;\/div&gt;\r\n<\/pre>\n<p>Next, to make it more clear, give this element some styling:<\/p>\n<pre class=\"brush:css\">\r\n&lt;!-- STYLE SECTION --&gt;\r\n&lt;style type=\"text\/css\"&gt;\r\n.dragme {\r\n        border-radius: 0.5em;\r\n        width: 12em;\r\n        height: 8em;\r\n        padding: 1em;\r\n        font-family: \"Montserrat\", \"Arial\";\r\n        background-color: #00C5CD;\r\n        color: white;\r\n    }\r\n&lt;\/style&gt;\r\n<\/pre>\n<p>Next, in your Javascript section, create a new function which finds the <code>.dragme<\/code> class and applies the <code>.draggable()<\/code> method to this class:<\/p>\n<pre class=\"brush:java\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n  $(function() {\r\n    $('.dragme').draggable();\r\n  });\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result would be a draggable element like this:<br \/>\n<figure id=\"attachment_6744\" aria-describedby=\"caption-attachment-6744\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-1.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-1.gif\" alt=\"Basic Draggable Functionality\" width=\"800\" height=\"500\" class=\"size-full wp-image-6744\" \/><\/a><figcaption id=\"caption-attachment-6744\" class=\"wp-caption-text\">Basic Draggable Functionality<\/figcaption><\/figure><\/p>\n<h2>2. Customized Draggable Elements<\/h2>\n<p>In this section, we&#8217;ll have a look at how much we can customize draggable elements to fit our needs.<\/p>\n<h3>2.1 Constraining Movement<\/h3>\n<p>Constrain the movement of each draggable by defining the boundaries of the draggable area. Set the axis option to limit the draggable&#8217;s path to the x- or y-axis, or use the containment option to specify a parent DOM element or a jQuery selector, like &#8216;document.&#8217; Let&#8217;s first use the <code>containment<\/code> to limit the area to a parent div:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION  --&gt;\r\n&lt;div class=\"drag-parent\"&gt;\r\n    &lt;div class=\"dragme\"&gt;Drag me!&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>Let&#8217;s give the parent div a little styling:<\/p>\n<pre class=\"brush:css\">\r\n&lt;!-- STYLE SECTION --&gt;\r\n&lt;style type=\"text\/css\"&gt;\r\n.drag-parent {\r\n    border: 0.1em solid #BA064E;\r\n    width: 45em;\r\n    height: 20em;\r\n}\r\n&lt;\/style&gt;\r\n<\/pre>\n<p>And now, let&#8217;s add the <code>containment<\/code> option to the <code>draggable()<\/code> method:<\/p>\n<pre class=\"brush:java\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n  $(function() {\r\n    $('.dragme').draggable({ containment: \".drag-parent\" });\r\n  });\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>This would result in a limited draggable area:<br \/>\n<figure id=\"attachment_6748\" aria-describedby=\"caption-attachment-6748\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-2.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-2.gif\" alt=\"Constraining Draggable Area using Containment\" width=\"800\" height=\"434\" class=\"size-full wp-image-6748\" \/><\/a><figcaption id=\"caption-attachment-6748\" class=\"wp-caption-text\">Constraining Draggable Area using Containment<\/figcaption><\/figure><\/p>\n<p>Now let&#8217;s constrain draggable area by axis, x or y. To do this, add the <code>axis<\/code> option to the <code>.draggable()<\/code> method and give it a value of <code>'x'<\/code> or <code>'y'<\/code> depending on what you are looking for.<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION  --&gt;\r\n    &lt;div class=\"dragme dragme-x\"&gt;Drag me by x!&lt;\/div&gt;\r\n    &lt;div class=\"dragme dragme-y\"&gt;Drag me by y!&lt;\/div&gt;\r\n<\/pre>\n<pre class=\"brush:java\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n  $(function() {\r\n    $('.dragme-x').draggable({ axis: \"x\" });\r\n    $('.dragme-y').draggable({ axis: \"y\" });\r\n  });\r\n&lt;\/script&gt;\r\n<\/pre>\n<figure id=\"attachment_6750\" aria-describedby=\"caption-attachment-6750\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-3.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-3.gif\" alt=\"Constrain Movement by Axis\" width=\"800\" height=\"434\" class=\"size-full wp-image-6750\" \/><\/a><figcaption id=\"caption-attachment-6750\" class=\"wp-caption-text\">Constrain Movement by Axis<\/figcaption><\/figure>\n<h3>2.2 Cursor Styles over Draggable Element<\/h3>\n<p>Position the cursor while dragging the object. By default the cursor appears in the center of the dragged object; use the <code>cursorAt<\/code> option to specify another location relative to the draggable (specify a pixel value from the <code>top<\/code>, <code>right<\/code>, <code>bottom<\/code>, and\/or <code>left<\/code>). Customize the cursor&#8217;s appearance by supplying the cursor option with a valid CSS cursor value: default, move, pointer, crosshair, etc.<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION  --&gt;\r\n    &lt;div class=\"dragme dragme-x dragme-crosshair\"&gt;Drag me by x!&lt;\/div&gt;\r\n    &lt;div class=\"dragme dragme-y dragme-move\"&gt;Drag me by y!&lt;\/div&gt;\r\n<\/pre>\n<pre class=\"brush:java\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$(function() {\r\n$('.dragme-crosshair').draggable({ cursor: \"crosshair\", cursorAt: { top: 80, left: 120 } });\r\n$('.dragme-move').draggable({ cursor: \"move\", cursorAt: { top: 90, left: 100 } });\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result would be a customized cursor while dragging our element:<br \/>\n<figure id=\"attachment_6755\" aria-describedby=\"caption-attachment-6755\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-4.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-4.gif\" alt=\"Cursor Styling on Draggable Elements\" width=\"800\" height=\"380\" class=\"size-full wp-image-6755\" \/><\/a><figcaption id=\"caption-attachment-6755\" class=\"wp-caption-text\">Cursor Styling on Draggable Elements<\/figcaption><\/figure><\/p>\n<h3>2.3 Revert Draggable Element Position<\/h3>\n<p>You can actually return the draggable (or it&#8217;s helper) to its original location when dragging stops with the boolean <code>revert<\/code> option.<\/p>\n<pre class=\"brush:java\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n  $(function() {\r\n    $( '.dragme' ).draggable({ revert: true });\r\n  });\r\n&lt;\/script&gt;\r\n<\/pre>\n<figure id=\"attachment_6762\" aria-describedby=\"caption-attachment-6762\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-5.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-5.gif\" alt=\"Revert Position\" width=\"800\" height=\"300\" class=\"size-full wp-image-6762\" \/><\/a><figcaption id=\"caption-attachment-6762\" class=\"wp-caption-text\">Revert Position<\/figcaption><\/figure>\n<p>Another useful option here would be <code>helper<\/code> with the value <code>clone<\/code>. That would create a clone of the element while dragging and still show the original element right in its inital position:<\/p>\n<pre class=\"brush:java\">\r\n  $(function() {\r\n    $( '.dragme' ).draggable({ revert: true, helper: \"clone\" });\r\n  });\r\n<\/pre>\n<figure id=\"attachment_6764\" aria-describedby=\"caption-attachment-6764\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-6.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-6.gif\" alt=\"Revert Position, Draggable Element is Cloned\" width=\"800\" height=\"300\" class=\"size-full wp-image-6764\" \/><\/a><figcaption id=\"caption-attachment-6764\" class=\"wp-caption-text\">Revert Position, Draggable Element is Cloned<\/figcaption><\/figure>\n<h3>2.4 Snap to Element or Grid<\/h3>\n<p>Snap the draggable to the inner or outer boundaries of a DOM element. Use the snap or snapMode (inner, outer, both).<br \/>\nOr snap the draggable to a grid. Set the dimensions of grid cells (height and width in pixels) with the grid option.<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION  --&gt;\r\n&lt;div class=\"drag-parent\"&gt;\r\n    &lt;div class=\"dragme dragme-normal\"&gt;I snap to all other draggable elements!&lt;\/div&gt;\r\n    &lt;div class=\"dragme dragme-x dragme-crosshair dragme-parent\"&gt;Drag me to my parent!&lt;\/div&gt;\r\n    &lt;div class=\"dragme dragme-y dragme-move dragme-grid\"&gt;Drag me to my grid!&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<pre class=\"brush:java\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n  $(function() {\r\n    $('.dragme-normal').draggable({ snap: true });\r\n    $('.dragme-parent').draggable({ snap: '.drag-parent' });\r\n    $('.dragme-grid').draggable({ grid: [ 50, 50 ] });\r\n  });\r\n&lt;\/script&gt;\r\n<\/pre>\n<figure id=\"attachment_6768\" aria-describedby=\"caption-attachment-6768\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-7.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-7.gif\" alt=\"Perform Snap to Element or Grid Functionality\" width=\"800\" height=\"444\" class=\"size-full wp-image-6768\" \/><\/a><figcaption id=\"caption-attachment-6768\" class=\"wp-caption-text\">Perform Snap to Element or Grid Functionality<\/figcaption><\/figure>\n<h2>3. An Advanced Approach<\/h2>\n<p>In a more professional and complete demo that you can find <a href=\"http:\/\/demos.telerik.com\/kendo-ui\/dragdrop\/index\" target=\"_blank\">here<\/a>, you can make this ultimate by adding or removing congtent (classes) on mouseover and mouseleave to complete the whole user experience for the modern web. The demo includes your source code for this:<br \/>\n<figure id=\"attachment_6770\" aria-describedby=\"caption-attachment-6770\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-8.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/draggable-8.gif\" alt=\"Telerik&#039;s Kendo UI Pro Demo of Drag and Drop\" width=\"800\" height=\"444\" class=\"size-full wp-image-6770\" \/><\/a><figcaption id=\"caption-attachment-6770\" class=\"wp-caption-text\">Telerik&#8217;s Kendo UI Pro Demo of Drag and Drop<\/figcaption><\/figure><\/p>\n<h2>4. Conclusion<\/h2>\n<p>Drag-and-drop with JavaScript used to be very hard to do \u2014 in fact, getting a decent cross-browser version working was next to impossible. However, with modern browsers and a smattering of jQuery, drag-and-drop is now a piece of cake! Dragging has a lot to customize and improve to make your UX perfect. Try out and see how you can get creative and productive!<\/p>\n<h2>5. Download<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/08\/jQuery-Drag-Drop.zip\"><strong>jQuery Drag &amp; Drop<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The aim of this example is to explain and use drag and drop functionality with jQuery. Basically, in jQuery you can enable draggable functionality on any DOM element and move the draggable object by clicking on it with the mouse and dragging it anywhere within the viewport. Dragging and dropping can be a very intuitive &hellip;<\/p>\n","protected":false},"author":75,"featured_media":919,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-6735","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>jQuery Drag and Drop Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"The aim of this example is to explain and use drag and drop functionality with jQuery. Basically, in jQuery you can enable draggable functionality on any\" \/>\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\/javascript\/jquery\/jquery-drag-drop-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"jQuery Drag and Drop Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"The aim of this example is to explain and use drag and drop functionality with jQuery. Basically, in jQuery you can enable draggable functionality on any\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-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:author\" content=\"https:\/\/www.facebook.com\/fabiocimo\" \/>\n<meta property=\"article:published_time\" content=\"2015-09-08T09:15:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-21T14:40:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-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=\"Fabio Cimo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fabiocimo\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fabio Cimo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/\"},\"author\":{\"name\":\"Fabio Cimo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\"},\"headline\":\"jQuery Drag and Drop Example\",\"datePublished\":\"2015-09-08T09:15:04+00:00\",\"dateModified\":\"2017-12-21T14:40:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/\"},\"wordCount\":762,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"articleSection\":[\"jQuery\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/\",\"name\":\"jQuery Drag and Drop Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"datePublished\":\"2015-09-08T09:15:04+00:00\",\"dateModified\":\"2017-12-21T14:40:04+00:00\",\"description\":\"The aim of this example is to explain and use drag and drop functionality with jQuery. Basically, in jQuery you can enable draggable functionality on any\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"jQuery\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/jquery\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"jQuery 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\/1dfb88b4a8d08c37a6080311fd330a22\",\"name\":\"Fabio Cimo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"caption\":\"Fabio Cimo\"},\"description\":\"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.\",\"sameAs\":[\"https:\/\/www.facebook.com\/fabiocimo\",\"https:\/\/al.linkedin.com\/in\/fabiocimo\",\"https:\/\/x.com\/fabiocimo\",\"https:\/\/www.youtube.com\/fabiocimo1\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"jQuery Drag and Drop Example - Web Code Geeks - 2026","description":"The aim of this example is to explain and use drag and drop functionality with jQuery. Basically, in jQuery you can enable draggable functionality on any","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\/javascript\/jquery\/jquery-drag-drop-example\/","og_locale":"en_US","og_type":"article","og_title":"jQuery Drag and Drop Example - Web Code Geeks - 2026","og_description":"The aim of this example is to explain and use drag and drop functionality with jQuery. Basically, in jQuery you can enable draggable functionality on any","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/fabiocimo","article_published_time":"2015-09-08T09:15:04+00:00","article_modified_time":"2017-12-21T14:40:04+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","type":"image\/jpeg"}],"author":"Fabio Cimo","twitter_card":"summary_large_image","twitter_creator":"@fabiocimo","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Fabio Cimo","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/"},"author":{"name":"Fabio Cimo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22"},"headline":"jQuery Drag and Drop Example","datePublished":"2015-09-08T09:15:04+00:00","dateModified":"2017-12-21T14:40:04+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/"},"wordCount":762,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","articleSection":["jQuery"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/","name":"jQuery Drag and Drop Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","datePublished":"2015-09-08T09:15:04+00:00","dateModified":"2017-12-21T14:40:04+00:00","description":"The aim of this example is to explain and use drag and drop functionality with jQuery. Basically, in jQuery you can enable draggable functionality on any","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-drag-drop-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"jQuery","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/jquery\/"},{"@type":"ListItem","position":4,"name":"jQuery 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\/1dfb88b4a8d08c37a6080311fd330a22","name":"Fabio Cimo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","caption":"Fabio Cimo"},"description":"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.","sameAs":["https:\/\/www.facebook.com\/fabiocimo","https:\/\/al.linkedin.com\/in\/fabiocimo","https:\/\/x.com\/fabiocimo","https:\/\/www.youtube.com\/fabiocimo1"],"url":"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/6735","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\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=6735"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/6735\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/919"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=6735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=6735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=6735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}