jQuery DragNDrop is to enable the drag and drop functionality in the list of items. DragNDrop is a jQuery plugin that allows you to rearrange an ordered (or unordered) HTML list using drag and drop. Without the need for jQuery UI.
html sort select options, html sort list, html sort list by date, how to sort drop down list in alphabetical order in html, html sort list alphabetically, javascript drag and drop reorder div
How to make use of it:
1. Download the JavaScript jquery.dragndrop.js and place it after the jQuery library.
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"> </script> <script src="./jquery.dragndrop.js"></script>
2. Just call the function in your HTML menu and the plugin will do the rest.
<ul class="demo"> <li> List Item 1 </li> <li> List Item 2 </li> <li> List Item 3 </li> ... </ul> <ol class="demo"> <li> List Item 1 </li> <li> List Item 2 </li> <li> List Item 3 </li> ... </ol>
$(function(){ $('.demo').dragndrop(); });
3. Get the menu item you just dropped.
$(function(){ $('.demo').dragndrop({ onDrop: function( element, droppedElement ) { console.log( 'element dropped: ' ); console.log( droppedElement ); } }); });
4. Reset position.
$('.demo').dragndrop('reset');
5. Disable/reconfigure the drag and drop functionality.
$('.demo').dragndrop('unload'); $('.demo').dragndrop('reload');
Options
Methods
unload Disable the jQuery Drag & Drop functionality.
reload Reload the jQuery Drag & Drop functionality. Useful if you dynamically add/remove items to be dragged and dropped.
reset Reset elements back to their original position when page loaded. NOT YET IMPLEMENTED
Callbacks
onDrop
Fires after element is dropped into its new position.
onDrop( element, droppedElement )
element: The original element targeted for .dragndrop().
droppedElement: The element that was moved.
See Demo And Download
Official Website(nobleclem): Click Here
This superior jQuery/javascript plugin is developed by nobleclem. For extra Advanced Usages, please go to the official website.