drag and drop sorting

// use id
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();


<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Sortable - Default functionality</title>
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <style>
  #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
  #sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; }
  #sortable li span { position: absolute; margin-left: -1.3em; }
  </style>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#sortable" ).sortable();
    $( "#sortable" ).disableSelection();
  } );
  </script>
</head>
<body>
 
<ul id="sortable">
    <label> welcome  </label>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 1</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 2</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 3</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 4</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 5</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 6</li>
  <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Item 7</li>
</ul>
 
 
</body>
</html>

3.6
5

                                    &lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
    &lt;title&gt;DRAG_AND_DROP&lt;/title&gt;
    &lt;style&gt;
  	body{
    background-color: aquamarine;
}
.whiteBox{
    height: 250px;
    width: 250px;
    background-color: rgb(55, 238, 245);
    margin: 10px;
    display: inline-block;
    border: 2px solid red;
}
.imgBox{

    display: flex;
    background-image: url(&quot;image.jpg&quot;);
    height: 230px;
    width: 230px;
    position: relative;
    top: 10px;
    margin:0 auto;
    cursor: pointer;

}
.imgBox1{

    display: flex;
    background-image: url(&quot;image.jpg&quot;);
    height: 230px;
    width: 230px;
    position: relative;
    top: 10px;
    margin:0 auto;
    cursor: pointer;

}
.hold{
    border: 2px dashed rgb(118, 182, 0);
}
.hide{
    display: none;
}
.dragenter{
    background: rgb(221, 115, 96);
    border-color: green;
    border-style: groove;
}
  	&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div class=&quot;whiteBox&quot;&gt;
        &lt;div class=&quot;imgBox&quot; draggable=&quot;true&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;whiteBox&quot;&gt;&lt;/div&gt;
    &lt;div class=&quot;whiteBox&quot;&gt;&lt;/div&gt;
    &lt;div class=&quot;whiteBox&quot;&gt;&lt;/div&gt;
    &lt;script&gt;
  	console.log(&quot;D&amp;D&quot;);

let imgBox = document.querySelector(&quot;.imgBox&quot;);
let whiteBoxes = document.querySelectorAll(&quot;.whiteBox&quot;);

imgBox.addEventListener(&quot;dragstart&quot;, (e) =&gt; {
  console.log(&quot;DRAG STARTED&quot;);
  e.target.className += &quot; hold&quot;;
  setTimeout(() =&gt; {
    e.target.className += &quot; hide&quot;;
  }, 0);
});
imgBox.addEventListener(&quot;dragend&quot;, (e) =&gt; {
  console.log(&quot;DRAG ENDED&quot;);
  e.target.className = &quot;imgBox&quot;;
});

for (whiteBox of whiteBoxes) {
  whiteBox.addEventListener(&quot;dragover&quot;, (e) =&gt; {
    e.preventDefault();
    // console.log(&quot;gj&quot;)
  });
  whiteBox.addEventListener(&quot;dragenter&quot;, (e) =&gt; {
    e.target.className += &quot; dragenter&quot;;
  });
  whiteBox.addEventListener(&quot;dragleave&quot;, (e) =&gt; {
    e.target.className = &quot;whiteBox&quot;;
  });
  whiteBox.addEventListener(&quot;drop&quot;, (e) =&gt; {
    let answer= confirm(&quot;Do you really want to move it&quot;)
    console.log(answer)
    if(answer){
        e.target.append(imgBox)}
        else{
            e.target.className = &quot;whiteBox&quot;;
       
    }
  });
}

  	&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

3.6 (5 Votes)
0
4.33
6
C69 75 points

                                    &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;https://code.jquery.com/ui/1.12.1/jquery-ui.js&quot;&gt;&lt;/script&gt;
  &lt;script&gt;
  $( function() {
    $( &quot;#sortable&quot; ).sortable();
    $( &quot;#sortable&quot; ).disableSelection();
  } );
  &lt;/script&gt;
  
&lt;div id=&quot;sortable&quot;&gt;
  &lt;div&gt;Item 1&lt;/div&gt;
  &lt;div&gt;Item 2&lt;/div&gt;
  &lt;div&gt;Item 3&lt;/div&gt;
  &lt;div&gt;Item 4&lt;/div&gt;
  &lt;div&gt;Item 5&lt;/div&gt;
  &lt;div&gt;Item 6&lt;/div&gt;
  &lt;div&gt;Item 7&lt;/div&gt;
&lt;/div&gt;
 

4.33 (6 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
jquery sortable table get order jquery sortable get elements understanding drag and drop Drag and drop editor to do drag and drop how drag and drop html drag and drop ansys query drag and drop jquery sortable in ph[ why cant i drag and drop sortable jquery conenctwith How to drag and drop create html jquery sortable methods drag and drop event drag jquery sortable to array drag and drop html site sortable with div jquery Drag and drop method drag and drop data structure sortable inside sortable jquery how to make a drag and drop ediot two way drag and drop drag drop w3 drag and drop website sortable in jquery drag and drop items what if i make draggable = false will drag and drop work How do I add drag and drop? you can use drag and drop method to drag and drop display on drag drag and drop instructions how does drag work sort list with jquery sortable sortable div jquery html drag and drop sorting jquery sorteable jquery sortable js jquery sortable order manafer drag and drop order list sortable tale jquery how to handle drag and drop in html jquery sortable new element drag and drop w3 dynamic drag and drop drag and drop fragen what is drag drop drag and drop sample jquery sortable lists how to do drag and drop in igTree drag and drop dragleave jquery sortable .sortable( &quot;anable&quot; ) jquery create element with sortable drag and drop brows jquery sortable usage best way to drag and drop drag and drop framework drag and drop data drag and sort order by drag and drop how to implement drag and drop in html5 jquery.sortable.j jquery Sortable api sortable js jquery jquery sortable ul Drag and drop htm drag and drop backend drag and drop ordering creating html css using drag drop drop and drag html html code to drag and drop drag and drop IOT drag and drop meaaning jquery sortable element order drag and drop architectur get order of sortable jquery drag and drop demo drag and drop correct Implement Drag and Drop how to create html statement drag and drop Drag and drop is a technique to drag drop tutorial drag and drop drop js jquery sortable() button sortable() jquery image drag and drop build drag and drop in html drag @ drop making drag and drop work drag and drop dynamic Drag and drop proplem jQuery sortable div drag and drop drop css drag and drop[ drag and drop defold drag and drop design example jquery sortable box oden drag drop how to make drag-and-drop in html jquery sort order for element list drag and drop effect create drag and drop html drag and droptodo drag &amp; drop elements drag and drop ide html drop and drag drag and drop html example d3 drag and drop example jquery sortable demo create drag and drop drag and drop possible using HTML5 and how html drag-and-drop jquery sortable handle drag and drop table drag and drop options make drag and drop html drag androp drag'n drop drag'ndrop drag and drop elements css froLO drag and drop drag and drop code dnd drag and drop code drag and drop sorting Drag and Drop in a box drag and drop operation css make drag and drop drag and drop area drag &amp; drop html drag and drop example in html css drag and drop function drag and drop to html code drag and drop in hmlt jquery sortable example code drag and drop web drag and drop design implement drag and drop javascript sortable div in jquery drop and drag sort results jquery drag and drop html5 example drag and drop in html5 sortablejs jquery HTML5 drag and drop example drag and drop definition drag and drop formula masory drag and drop drag and dropp create html with drag and drop html simple drag drop what created drag and drop order array in jquery sort desc jquery sortable js example example with jQuery SortableJS dnd drag and drop make a drag and drop Drag and Drop codehs (jQuery,window,&quot;Sortable&quot;) sortable div jquery example drag and drop plugin html drag and drop vs javascript drag and drop how to add drag and drop in html drag and drop line sortable method in jquery using drag and drop how to sort a table html javascript jquery menu Drag and Drop sort using jquery jquery sortable on html drag $&amp; drop drag drop imbriqu&eacute; create html by drag and drop jquery.sortable drag an drop in html drag and droping drag &amp; drop website jquery orderable drag and drop implementation drag and srop d3 drag and drop drag and drop d3 html drag drop sort order with jquery html drag and droper jquery sortable sortable jquery evento Drag and drop. jquery .sortable jquery sortable docs jquery sortable options drag and drop simple example dragula drag and drop jquery sortable examples drag and drop to code drag and drop in anmtd drag and drop box sortable jquery with find .sortable jquery sortable event jquery How to add drag and drop in HTML? sortable jquery order arrange drag and drope drag and drop position how to make a drag and drop in html jquery sortable get order sortable function in jquery drag and drop select how to make a drag and' drop in html simple drag drop html5 drag and drop native dargand drop api javascript draggable on drop drag and drop divs how to set different style while drag in html css javascript jquery sort items jquery ui multi level list group dragable react drag and drop jquery.sortable.js how to drag and drop elements using js Sortable in js drag and drop with value jquery sortable list library list drag and drop jquery java script drag and drop drag and drop in a bar html html draggable sampe w3 html draggable item -drop php drag and drop sortable javascript how to drag and drop in html drag and drop events example javascript order by jquery sort jquery draggable list reorder drag and drop css html html on draging ui-sortable html jq Sortable on drop function drag and drop div javascript drag and drop sortable jquery sort library jquery ui on sort complete drag and drop p&aring; dansk JAVASCipt drag and drop drag and drop jquery example drap and drop a file w3schools jq drag and drop elements to reorder callback function jq drag and drop elements to reorder how to sort element lists with jquery ui sortable sort list elements in jquery ui sortable drag and drop image html where go the dragged element sortable get order css add drag and dorp jquery order list jquery sortable putting in other jquery sortable array html5 drag html 5 drag html5 drag and drop list example jquery ui sortable get sorted list drag and drop css html website datatransfer javascript w3schools sorting drang and drop make drag and drop boxes html ui-sortable-handle jquery drag and drop function in javascript jquery drag and rearrange div Drag'n'drop css div drag and drop jquery sorting method example using jquery-ui sortable example using jquery sortable drag n droo drag and drop box html interact drag and drop drag drop w3schools drag and drop example website drag and drop in website how to add droppable of in the sortable js html 5 drag and drop draggable w3schools movable list drag in drop drag items css jquery ui draggable sortable cards drag and drop file w3schools sortable example image can drag html image drag and drop javascript drag and drop layout making html php drag and drop boxes html html object drag and drop jQuery drag and drop sorting drag drop events javascript drag and drop php html drag and sort drag and drop example html js drag drop html5 drag and drop html blocks sortable-field-handler javscript javascript drag and drop events jquery sortable how to get the order jquery draggable and sortable drag and drop outside browser drag and drop functionality alpine drag and drop drag and drop js library drag and drop jsfiddle drag and drop drag css css for drag and drop drag and drop on image html jquery sortable list html sortable list drag drop sorting jquery .draggable add drag to dom elements alpine js drag and drop drag and move elements in html drag and move html drag and drop html elements javascript native drag and drop list with draggable option simple drag and drop js drag and ndrop css drag drop js jquery #sortable drag and drop jq js draggable drug and drop js how to drag and drop in javascript jquery shortable drag and drop to do how to support drag and drop jquery makesortable draggable api drag-drop image code drag and drop drag and drop js api drag n drop js api enable drag on html ES6 drag and drop html5 drag and drop image drag html drag drop div how to drag php tract drag and drop jquery sortable functions jquery sortable not accept drag and drop drag and drop ordering jquery jquery sortable recieve jquery on sortable change jquery sortable specify items jquery sortable example drag and drop dom elements :dragging css javascript drag and drop objects js html drag and drop jquery drag order list jquery draggable list drag and drop text in html jquery ui draggable list drag on html how to make a input to dragw on html bootstrap drag and drop file upload w3schools how to create drag and drop area using html and js jquery ui sort list drag sortable events drag drop javascript sortable jquery get order fdrag and drop js html5 allows element to dragged and dropped inside an HTMLpage which needs to be called to prevent the brower default drag and drop handling of data js drang and drop jquery drag and drop list vis js drag and drop drag and drop a container element html javascript drag and drop example with dropdown html drop image drago and drop items css sortable click css sortable list how to drag and drop in hrml css how drag and drop data in html how drag and drop item in html how to drag and drop div how to restrict the area of drag and drop in html drag &amp; drop jquery ui movable ho to make drag and drop in HTMl drag and drop events js html drag and drop api tutorial jquery html5 list drag and drop example how to implement drag and drop sortable jquery sortable jquery example javascript implement drag and drop html drag and drop modify drag and drop elements js drop event js drag events drag events drag and drop in jquery drag and drop on div multi dom element sortable in jquery ui javascript event drag and drop drag and drop items javascript order table jquery drag sort jquery sortable items drag and drop html5 how to drag and drop a div in html how to make html drag and drop sortable js how to drag and drop drop page css and html page drop html click and drag css technique drag and drop using jaavascript jquery order list drag drop drag and drop a image in java script create table on drag and drop event javascrip drag and drop js code to a drug and drop w3schools drag and drop html5 drag drop api html drag and drop div html drag and drop html css on drag html dnd example code for drag and drop javascript html drag component hmtl drag and drop javascript exercises html5 drag and drop mouse events ui sortable html5 draggable make a div droppable how to make drag and drop with html javascript drag and drop api jquery-sortable js example detect drag and drop css Sotrable example drag drop sort drag drop api html5 how to drag and Drop html js drag and drop item drag&amp;drop html drag and drop file upload w3schools drag and drop jquery list js drag and drop events draw e drop js javascript drag and drop items Drag And Drop Script html css drag n drop div how to make a drag and drop with javascript jquery jquery ui order drag and drop js code sort table jquery API Drag and drop js drag and drop element $.ui.sortable html js drag and drop jquery ui drag and drop list jquery sortable drag and drop list javascript drag and drop example jquery sortable download sortable in javascript drag nad drop javascirpt drag and drop example in javascript html css drag and drop show earth draggable area html5 drag and drop js jquery table sortable drag and drop html make an element receive drop drag and drop image in html js drag and drop elements js javascript drag and drop bootstrap drag and drop interface javascript drag and drop fields html code on drop element html drag-drop html drag and drop box drag and drop links to create html page drag and drop links to html drag and drop text to html jquery sortable drag and drop html and css codes html drag drop api ele.sortable() in jquery sortable order jquery drag drop append value to drop html element drag n drop code file drag and drop html 5 drag drop events w3school drag drop drag and drop events how to make div droppable drag drop images grag and drop html css div drag and drop drag n drop how to create drag and drop elements in html drag and drop using css drag n drop js dragdrop html what websites use drag and drop javascript js drag n drop w3c html drag img into html on drop javascirpt drag drag and drop field html drag and drop image in html drop over image in html drag in javascript drag javascript drag and drop w3c drag and drop example html drag css can we develop html with drag and drop drag in js drag images html drag drop css make drag and drop javascript how to create drag and drop in html html drag and drop file w3schools drag an html drag and drop css javascript drag and drop to html drag drop in html5 examples how to drag and drop image in html into a div drag and drop area html html5 drag and drop api drag-and-drop components in javascript drag.js example how to make drag and drop in html how to use drag and drop html simple html5 drag and drop drag and drop html 5 HTML Drag and Drop examples how to drag n drop element js jquery droppable code example w3schools drag and drop form in html5 drag and drop tag in html5 how to create drag and drop in the DOM drag and drop a drop and darg api drag an drop image css html drag and drop effects in html5 drag and drop html css drag and drop in css drag and drop example drag and drop image html drop image html drag drop html dragzone allow drag drop guide lines for 4 sides javascript html drag drop guidelines for 4 sides javascript html drag guidelines for 4 sides javascript html drag guidelines for 4 sides html5 drag guid for 4 sides htnl5 drag and drop div javascript drag and drop tutorial html file drag and drop drag n drop javascript web drag and drop image drage and drop html drag and drop example text field html drag and drop example textfield css drag and drop js drag event drag and drop html javascript drag and drop html div drag and drop image in javascript drag and drop set value drag and drop image javascript HTML Drag and Drop API drag and drop html js image drag and drop with css html5 drag drop drag and dop css css drag drop drag and drop to css javascript drag drag and drop w3 school how drag and drop websites works in javascript drag and drop css div drag and drop drag drag and drop features drag and drop example in html5 drag img drag and drop image example page DRAG AND DROP WITH HTML HTML Drag and Drop API example bootstrap drag drop add dragging of elements html html dop itens element drag and drop w3 drag api set allowdrop drag property with jquery Simple Drag and Drop html drag text drag and drop to html dragging dom elements drag and drop w3schools drag and drop v3schools .drag javascript drag js javascript for drag and drop drag and drop html javascript css drag and drop implement drag and drop n html read drag drop a href drop event link html javascript function html javascript drag and drop simple code drag and drop jquery drag and drop example drag and drop element js jquery drag and drop html drag and drop eventa drag and dropjavascript how to make drag and drope option html drag and drop example drag and drop bootstrap drag and drop in js drag and drop examples drag and drop examples javascript drag and drop api javascript html/scc drag and drop drag and drop examples using javascript bootstrap drag and drop html5 drag and drop image get and display example javascript draging and drop drag drop page how to write something after dropend html5 drag and drop javascript demo drag and drop API js html css drag and drop drag and drop css html drag and drop list javascript drag drop how to drag and drop using javascript drag and drop tutorial javascript drag item html drag drop drag n drop jquery from div drag to droplist drag and edit element draggable html5 drag and drop htmlk drop and drag js drag and drop effect css drag and drop images drop html html5 drag and drop js drag drop drag and drop javascript drop image example html5 css3 drag and drop builder in javascript html5 css3 drag and drop drag and drop in html javascript drag and drop js drag and drop draggable html5 drag/drop api droppable html how to make a drag and drop system in javascript how to make drag and drop image in html drag and drop in bootstrap drag drop comment html How to make drag and drop in Javascript? drag and drop text box in java javascript html5 drag drop example drag drop html html drag and srop example drag &amp; drop js drag and drop jquery drag and drop in javascript create html drag and drop drag and drop api drag and drop html drag and drop javascript html html drag and drop css drag drag and drop elements in html css html crag and drop drag and drop php js drag and drop
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source