Skip to content

A minimal JavaScript of a sortable (Drag and Drop) List. Vanilla Js

License

Notifications You must be signed in to change notification settings

KASRA10/JS-Sortable-List

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Draggable & Editable List

A minimal JavaScript project for creating and managing a draggable and editable list.

---

## HTML Basics

### `<ul>` and `<li>`
- **`<ul>`**: Unordered List. Creates a bullet-point list.
- **`<li>`**: List Item. Each item in a `<ul>` or `<ol>` is wrapped in `<li>`.

**Example:**
```html
<ul>
  <li>Apple</li>
  <li>Banana</li>
  <li>Orange</li>
</ul>

<ol> and <li>

  • <ol>: Ordered List. Creates a numbered list.
  • <li>: List Item. Each item in a <ol> is wrapped in <li>.

Example:

<ol>
  <li>First</li>
  <li>Second</li>
  <li>Third</li>
</ol>

Drag and Drop

  • Drag and Drop is a user interface feature that allows users to click and hold an object, drag it to a new location, and release it to "drop" it there.
  • In this project, it means users can reorder list items by dragging them up or down.

JavaScript

  • JavaScript (JS) is a programming language used to make web pages interactive.
  • It runs in the browser and can change HTML, CSS, and respond to user actions (like clicks, drags, etc.).

Usage

  1. Add new items using the input field.
  2. Drag items to reorder.
  3. Double-click an item to edit it.
  4. Click the delete button to remove an item.

jQuery UI Example

Here’s a simple example using jQuery UI to make a list draggable:

HTML:

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
  <ul id="sortable">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
  </ul>

  <script>
    $(function() {
      $("#sortable").sortable();
      $("#sortable").disableSelection();
    });
  </script>
</body>
</html>

How it works:

  • The list items can be dragged and reordered.
  • jQuery UI’s sortable() function makes the list draggable.

Technologies

  • HTML5
  • CSS3
  • Vanilla JavaScript
  • jQuery UI (optional)

Cinbtribution

Allowd to Imporve this Educational Code.

About

A minimal JavaScript of a sortable (Drag and Drop) List. Vanilla Js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published