Enable HTML5-Based Drag-and-Drop Functionality In The List of Items | jQuery DragNDrop

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.

Reorder HTML List Using Drag And Drop, jQuery DragNDrop Plugin/Github, html5 drag and drop reorder list, html draggable list

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.

Related Posts

svg-pan-zoom-container

Adding Zoom-on-Wheel and Pan-on-Drag to Inline SVG Elements

Vanilla-js module for adding zoom and panning behavior when dragging to SVG embedded elements. A lightweight Vanilla JavaScript plugin that enables zoom and pan functions on an…

html-table-sortable-js

Sorting HTML Table Vanilla JavaScript Library | Sortable.js

Sortable – Small JS vanilla table sorter makes any table with class = “sortable“, er, sortable. That is, the user can click the table header and change…

WYSIWYG-Rich-Text-Editor

WYSIWYG Rich Text Editor With jQuery And FontAwesome | RichText

RichText jQuery implementation for WYSIWYG Rich Text Editor which uses Font Awesome Iconic Font for editor icons. It is licensed under AGPL-3.0. Initialize editor Simply call .richText() on your jQuery(‘textarea’) or jQuery(‘input’)…

email-domain-autocomplete-genie

[Autocomplete] Email Domain Suggestions Like Gmail, Outlook, or More | email-genie

Email Genie allows auto-completion in the email field by providing a list of domain suggestions (gmail.com, outlook.com, etc.). This package is lightweight, flexible, compatible with libraries (jQuery,…

JavaScript-Library-for-Creating-Squircley-Magic

[Generator] JavaScript Library for Creating Squircley Magic ✨ | squircley.js

squircley.js is the core magic of Squirclular ✨ from https://squircley.app wrapped in a simple 0-dependency JavaScript library. squircley.js can generate SVG files, add square backgrounds to DOM…