{"id":9423,"date":"2024-01-10T18:02:00","date_gmt":"2024-01-10T18:02:00","guid":{"rendered":"https:\/\/codehim.com\/?p=9423"},"modified":"2024-01-22T16:03:35","modified_gmt":"2024-01-22T11:03:35","slug":"draggable-table-rows-in-javascript","status":"publish","type":"post","link":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/","title":{"rendered":"Draggable Table Rows In JavaScript"},"content":{"rendered":"<p>This JavaScript code snippet helps you to create draggable table rows on a webpage. It allows users to easily drag-and-drop sorting of table rows. It works by enabling you to click and drag table rows to rearrange their order. This functionality is helpful for creating interactive tables where users can easily reorder rows to suit their preferences.<\/p>\n<h2>How to Create Draggable Table Rows In JavaScript<\/h2>\n<p>1. Begin by creating an HTML structure for your table. Make sure to include the necessary HTML elements, like the <code>&lt;table&gt;<\/code>, <code>&lt;thead&gt;<\/code>, and <code>&lt;tbody&gt;<\/code>. For example:<\/p>\n<pre class=\"prettyprint linenums lang-html\">&lt;p&gt;Drag n' Drop sorting of rows!&lt;\/p&gt;\r\n&lt;table id=\"table\" class=\"draggable-table\"&gt;\r\n  &lt;thead&gt;\r\n    &lt;th&gt;Name&lt;\/th&gt;\r\n    &lt;th&gt;Occupation&lt;\/th&gt;\r\n  &lt;\/thead&gt;\r\n  &lt;tbody&gt;\r\n    &lt;tr&gt;\r\n      &lt;td&gt;April Douglas&lt;\/td&gt;\r\n      &lt;td&gt;Health Educator&lt;\/td&gt;\r\n    &lt;\/tr&gt;\r\n    &lt;tr&gt;\r\n      &lt;td&gt;Salma Mcbride&lt;\/td&gt;\r\n      &lt;td&gt;Mental Health Counselor&lt;\/td&gt;\r\n    &lt;\/tr&gt;  \r\n    &lt;tr&gt;\r\n      &lt;td&gt;Kassandra Donovan&lt;\/td&gt;\r\n      &lt;td&gt;Makeup Artists&lt;\/td&gt;\r\n    &lt;\/tr&gt; \r\n    &lt;tr&gt;\r\n      &lt;td&gt;Yosef Hartman&lt;\/td&gt;\r\n      &lt;td&gt;Theatrical and Performance&lt;\/td&gt;\r\n    &lt;\/tr&gt;\r\n    &lt;tr&gt;\r\n      &lt;td&gt;Ronald Mayo&lt;\/td&gt;\r\n      &lt;td&gt;Plant Etiologist&lt;\/td&gt;\r\n    &lt;\/tr&gt;  \r\n    &lt;tr&gt;\r\n      &lt;td&gt;Trey Woolley&lt;\/td&gt;\r\n      &lt;td&gt;Maxillofacial Surgeon&lt;\/td&gt;\r\n    &lt;\/tr&gt;  \r\n  &lt;\/tbody&gt;\r\n&lt;\/table&gt;\r\n<\/pre>\n<p>Customize the table with your data by adding rows and columns within the <code>&lt;tbody&gt;<\/code>. You can insert additional <code>&lt;tr&gt;<\/code> elements with corresponding <code>&lt;td&gt;<\/code> elements inside the <code>&lt;tbody&gt;<\/code>.<\/p>\n<p>2. Include the following CSS code in your HTML document to style the table and the draggable rows. This code will define the appearance of your table and the dragging effect:<\/p>\n<pre class=\"prettyprint linenums lang-css\">* {\r\n  font-family: \"Source Sans Pro\", sans-serif;\r\n}\r\n\r\nbody{\r\n  padding: 0;\r\n  margin: 0;\r\n  width: 100%;\r\n  height: 100vh;\r\n  background: #cb38e9;\r\n  position: relative;\r\n  background: radial-gradient(circle, #cb38e9 0%, #842fa8 100%) !important;\r\n}\r\n\r\n p {\r\n  font-size: 0.75em;\r\n  font-weight: bold;\r\n  position: absolute;\r\n  top: 15%;\r\n  width: 100%;\r\n  letter-spacing: 5px;\r\n  text-transform: uppercase;\r\n  text-align: center;\r\n  color: white;\r\n  user-select: none;\r\n}\r\n\r\n.draggable-table {\r\n  position: absolute;\r\n  top: 25%;\r\n  left: 20%;\r\n  width: 60%;\r\n  height: 50%;\r\n  border-collapse: collapse;\r\n  background: white;\r\n  -webkit-box-shadow: 0px 0px 10px 8px rgba(0, 0, 0, 0.1);\r\n  box-shadow: 0px 0px 10px 8px rgba(0, 0, 0, 0.1);\r\n}\r\n.draggable-table .draggable-table__drag {\r\n  font-size: 0.95em;\r\n  font-weight: lighter;\r\n  text-transform: capitalize;\r\n  position: absolute;\r\n  width: 100%;\r\n  text-indent: 50px;\r\n  border: 1px solid #f1f1f1;\r\n  z-index: 10;\r\n  cursor: grabbing;\r\n  -webkit-box-shadow: 2px 2px 3px 0px rgba(0, 0, 0, 0.05);\r\n  box-shadow: 2px 2px 3px 0px rgba(0, 0, 0, 0.05);\r\n  opacity: 1;\r\n}\r\n.draggable-table thead th {\r\n  height: 25px;\r\n  font-weight: bold;\r\n  text-transform: capitalize;\r\n  padding: 10px;\r\n  user-select: none;\r\n}\r\n.draggable-table tbody tr {\r\n  cursor: grabbing;\r\n}\r\n.draggable-table tbody tr td {\r\n  font-size: 0.95em;\r\n  font-weight: lighter;\r\n  text-transform: capitalize;\r\n  text-indent: 50px;\r\n  padding: 10px;\r\n  user-select: none;\r\n  border-top: 1px solid whitesmoke;\r\n}\r\n.draggable-table tbody tr:nth-child(even) {\r\n  background-color: #f7f7f7;\r\n}\r\n.draggable-table tbody tr:nth-child(odd) {\r\n  background-color: #ffffff;\r\n}\r\n.draggable-table tbody tr.is-dragging {\r\n  background: #f1c40f;\r\n}\r\n.draggable-table tbody tr.is-dragging td {\r\n  color: #ffe683;\r\n}<\/pre>\n<p>3. Now, you&#8217;ll need to include the JavaScript code given. This code handles the logic for dragging and reordering the table rows. Place the following JavaScript code just before the closing <code>&lt;\/body&gt;<\/code> tag:<\/p>\n<pre class=\"prettyprint linenums lang-js\">(function() {\r\n  \"use strict\";\r\n  \r\n  const table = document.getElementById('table');\r\n  const tbody = table.querySelector('tbody');\r\n  \r\n  var currRow = null,\r\n      dragElem = null,\r\n      mouseDownX = 0,\r\n      mouseDownY = 0,         \r\n      mouseX = 0,\r\n      mouseY = 0,      \r\n      mouseDrag = false;  \r\n  \r\n  function init() {\r\n    bindMouse();\r\n  }\r\n  \r\n  function bindMouse() {\r\n    document.addEventListener('mousedown', (event) =&gt; {\r\n      if(event.button != 0) return true;\r\n      \r\n      let target = getTargetRow(event.target);\r\n      if(target) {\r\n        currRow = target;\r\n        addDraggableRow(target);\r\n        currRow.classList.add('is-dragging');\r\n\r\n\r\n        let coords = getMouseCoords(event);\r\n        mouseDownX = coords.x;\r\n        mouseDownY = coords.y;      \r\n\r\n        mouseDrag = true;   \r\n      }\r\n    });\r\n    \r\n    document.addEventListener('mousemove', (event) =&gt; {\r\n      if(!mouseDrag) return;\r\n      \r\n      let coords = getMouseCoords(event);\r\n      mouseX = coords.x - mouseDownX;\r\n      mouseY = coords.y - mouseDownY;  \r\n      \r\n      moveRow(mouseX, mouseY);\r\n    });\r\n    \r\n    document.addEventListener('mouseup', (event) =&gt; {\r\n      if(!mouseDrag) return;\r\n      \r\n      currRow.classList.remove('is-dragging');\r\n      table.removeChild(dragElem);\r\n      \r\n      dragElem = null;\r\n      mouseDrag = false;\r\n    });    \r\n  }\r\n  \r\n  \r\n  function swapRow(row, index) {\r\n     let currIndex = Array.from(tbody.children).indexOf(currRow),\r\n         row1 = currIndex &gt; index ? currRow : row,\r\n         row2 = currIndex &gt; index ? row : currRow;\r\n         \r\n     tbody.insertBefore(row1, row2);\r\n  }\r\n    \r\n  function moveRow(x, y) {\r\n    dragElem.style.transform = \"translate3d(\" + x + \"px, \" + y + \"px, 0)\";\r\n    \r\n    let\tdPos = dragElem.getBoundingClientRect(),\r\n        currStartY = dPos.y, currEndY = currStartY + dPos.height,\r\n        rows = getRows();\r\n\r\n    for(var i = 0; i &lt; rows.length; i++) {\r\n      let rowElem = rows[i],\r\n          rowSize = rowElem.getBoundingClientRect(),\r\n          rowStartY = rowSize.y, rowEndY = rowStartY + rowSize.height;\r\n\r\n      if(currRow !== rowElem &amp;&amp; isIntersecting(currStartY, currEndY, rowStartY, rowEndY)) {\r\n        if(Math.abs(currStartY - rowStartY) &lt; rowSize.height \/ 2)\r\n          swapRow(rowElem, i);\r\n      }\r\n    }    \r\n  }\r\n  \r\n  function addDraggableRow(target) {    \r\n      dragElem = target.cloneNode(true);\r\n      dragElem.classList.add('draggable-table__drag');\r\n      dragElem.style.height = getStyle(target, 'height');\r\n      dragElem.style.background = getStyle(target, 'backgroundColor');     \r\n      for(var i = 0; i &lt; target.children.length; i++) {\r\n        let oldTD = target.children[i],\r\n            newTD = dragElem.children[i];\r\n        newTD.style.width = getStyle(oldTD, 'width');\r\n        newTD.style.height = getStyle(oldTD, 'height');\r\n        newTD.style.padding = getStyle(oldTD, 'padding');\r\n        newTD.style.margin = getStyle(oldTD, 'margin');\r\n      }      \r\n      \r\n      table.appendChild(dragElem);\r\n\r\n    \r\n      let tPos = target.getBoundingClientRect(),\r\n          dPos = dragElem.getBoundingClientRect();\r\n      dragElem.style.bottom = ((dPos.y - tPos.y) - tPos.height) + \"px\";\r\n      dragElem.style.left = \"-1px\";    \r\n    \r\n      document.dispatchEvent(new MouseEvent('mousemove',\r\n        { view: window, cancelable: true, bubbles: true }\r\n      ));    \r\n  }  \r\n  \r\n\r\n  function getRows() {\r\n    return table.querySelectorAll('tbody tr');\r\n  }    \r\n  \r\n  function getTargetRow(target) {\r\n      let elemName = target.tagName.toLowerCase();\r\n\r\n      if(elemName == 'tr') return target;\r\n      if(elemName == 'td') return target.closest('tr');     \r\n  }\r\n  \r\n  function getMouseCoords(event) {\r\n    return {\r\n        x: event.clientX,\r\n        y: event.clientY\r\n    };    \r\n  }  \r\n  \r\n  function getStyle(target, styleName) {\r\n    let compStyle = getComputedStyle(target),\r\n        style = compStyle[styleName];\r\n\r\n    return style ? style : null;\r\n  }  \r\n  \r\n  function isIntersecting(min0, max0, min1, max1) {\r\n      return Math.max(min0, max0) &gt;= Math.min(min1, max1) &amp;&amp;\r\n             Math.min(min0, max0) &lt;= Math.max(min1, max1);\r\n  }  \r\n  \r\n  \r\n  \r\n  init();\r\n  \r\n})();<\/pre>\n<p>That&#8217;s all! hopefully, you have successfully created an HTML table with draggable rows on your website. If you have any questions or suggestions, feel free to comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This JavaScript code snippet helps you to create draggable table rows on a webpage. It allows users to easily drag-and-drop&#8230;<\/p>\n","protected":false},"author":1,"featured_media":9434,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[116],"tags":[237],"class_list":["post-9423","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vanilla-javascript","tag-drag-and-drop"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Draggable Table Rows In JavaScript &#8212; CodeHim<\/title>\n<meta name=\"description\" content=\"Here is a free code snippet to create a Draggable Table Rows In JavaScript. You can view demo and download the source code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Draggable Table Rows In JavaScript &#8212; CodeHim\" \/>\n<meta property=\"og:description\" content=\"Here is a free code snippet to create a Draggable Table Rows In JavaScript. You can view demo and download the source code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"CodeHim\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codehimofficial\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-10T18:02:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-22T11:03:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Draggable-Table-Rows-In-JavaScript.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"960\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Asif Mughal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CodeHimOfficial\" \/>\n<meta name=\"twitter:site\" content=\"@CodeHimOfficial\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Asif Mughal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/\"},\"author\":{\"name\":\"Asif Mughal\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\"},\"headline\":\"Draggable Table Rows In JavaScript\",\"datePublished\":\"2024-01-10T18:02:00+00:00\",\"dateModified\":\"2024-01-22T11:03:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/\"},\"wordCount\":206,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Draggable-Table-Rows-In-JavaScript.png\",\"keywords\":[\"Drag and Drop\"],\"articleSection\":[\"Vanilla JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/\",\"url\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/\",\"name\":\"Draggable Table Rows In JavaScript &#8212; CodeHim\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Draggable-Table-Rows-In-JavaScript.png\",\"datePublished\":\"2024-01-10T18:02:00+00:00\",\"dateModified\":\"2024-01-22T11:03:35+00:00\",\"description\":\"Here is a free code snippet to create a Draggable Table Rows In JavaScript. You can view demo and download the source code.\",\"breadcrumb\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#primaryimage\",\"url\":\"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Draggable-Table-Rows-In-JavaScript.png\",\"contentUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Draggable-Table-Rows-In-JavaScript.png\",\"width\":1280,\"height\":960,\"caption\":\"Draggable Table Rows In JavaScript\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codehim.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Vanilla JavaScript\",\"item\":\"https:\/\/codehim.com\/category\/vanilla-javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Draggable Table Rows In JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codehim.com\/#website\",\"url\":\"https:\/\/codehim.com\/\",\"name\":\"CodeHim\",\"description\":\"Web Design Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"alternateName\":\"Web Design Codes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codehim.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/codehim.com\/#organization\",\"name\":\"CodeHim - Web Design Code & Scripts\",\"url\":\"https:\/\/codehim.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg\",\"contentUrl\":\"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg\",\"width\":280,\"height\":280,\"caption\":\"CodeHim - Web Design Code & Scripts\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/codehimofficial\",\"https:\/\/x.com\/CodeHimOfficial\",\"https:\/\/www.instagram.com\/codehim\/\",\"https:\/\/www.linkedin.com\/company\/codehim\",\"https:\/\/co.pinterest.com\/codehim\/\",\"https:\/\/www.youtube.com\/@codehim\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\",\"name\":\"Asif Mughal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g\",\"caption\":\"Asif Mughal\"},\"description\":\"I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences. I truly enjoy what I'm doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.\",\"sameAs\":[\"https:\/\/codehim.com\"],\"url\":\"https:\/\/codehim.com\/author\/asif-mughal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Draggable Table Rows In JavaScript &#8212; CodeHim","description":"Here is a free code snippet to create a Draggable Table Rows In JavaScript. You can view demo and download the source code.","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:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Draggable Table Rows In JavaScript &#8212; CodeHim","og_description":"Here is a free code snippet to create a Draggable Table Rows In JavaScript. You can view demo and download the source code.","og_url":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/","og_site_name":"CodeHim","article_publisher":"https:\/\/www.facebook.com\/codehimofficial","article_published_time":"2024-01-10T18:02:00+00:00","article_modified_time":"2024-01-22T11:03:35+00:00","og_image":[{"width":1280,"height":960,"url":"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Draggable-Table-Rows-In-JavaScript.png","type":"image\/png"}],"author":"Asif Mughal","twitter_card":"summary_large_image","twitter_creator":"@CodeHimOfficial","twitter_site":"@CodeHimOfficial","twitter_misc":{"Written by":"Asif Mughal","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#article","isPartOf":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/"},"author":{"name":"Asif Mughal","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed"},"headline":"Draggable Table Rows In JavaScript","datePublished":"2024-01-10T18:02:00+00:00","dateModified":"2024-01-22T11:03:35+00:00","mainEntityOfPage":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/"},"wordCount":206,"commentCount":2,"publisher":{"@id":"https:\/\/codehim.com\/#organization"},"image":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Draggable-Table-Rows-In-JavaScript.png","keywords":["Drag and Drop"],"articleSection":["Vanilla JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/","url":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/","name":"Draggable Table Rows In JavaScript &#8212; CodeHim","isPartOf":{"@id":"https:\/\/codehim.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#primaryimage"},"image":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Draggable-Table-Rows-In-JavaScript.png","datePublished":"2024-01-10T18:02:00+00:00","dateModified":"2024-01-22T11:03:35+00:00","description":"Here is a free code snippet to create a Draggable Table Rows In JavaScript. You can view demo and download the source code.","breadcrumb":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#primaryimage","url":"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Draggable-Table-Rows-In-JavaScript.png","contentUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2023\/10\/Draggable-Table-Rows-In-JavaScript.png","width":1280,"height":960,"caption":"Draggable Table Rows In JavaScript"},{"@type":"BreadcrumbList","@id":"https:\/\/codehim.com\/vanilla-javascript\/draggable-table-rows-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codehim.com\/"},{"@type":"ListItem","position":2,"name":"Vanilla JavaScript","item":"https:\/\/codehim.com\/category\/vanilla-javascript\/"},{"@type":"ListItem","position":3,"name":"Draggable Table Rows In JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/codehim.com\/#website","url":"https:\/\/codehim.com\/","name":"CodeHim","description":"Web Design Code Snippets","publisher":{"@id":"https:\/\/codehim.com\/#organization"},"alternateName":"Web Design Codes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codehim.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codehim.com\/#organization","name":"CodeHim - Web Design Code & Scripts","url":"https:\/\/codehim.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/#\/schema\/logo\/image\/","url":"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg","contentUrl":"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg","width":280,"height":280,"caption":"CodeHim - Web Design Code & Scripts"},"image":{"@id":"https:\/\/codehim.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codehimofficial","https:\/\/x.com\/CodeHimOfficial","https:\/\/www.instagram.com\/codehim\/","https:\/\/www.linkedin.com\/company\/codehim","https:\/\/co.pinterest.com\/codehim\/","https:\/\/www.youtube.com\/@codehim"]},{"@type":"Person","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed","name":"Asif Mughal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g","caption":"Asif Mughal"},"description":"I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences. I truly enjoy what I'm doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.","sameAs":["https:\/\/codehim.com"],"url":"https:\/\/codehim.com\/author\/asif-mughal\/"}]}},"views":5418,"_links":{"self":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/9423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/comments?post=9423"}],"version-history":[{"count":0,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/9423\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media\/9434"}],"wp:attachment":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media?parent=9423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/categories?post=9423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/tags?post=9423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}