-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.list2.html
59 lines (54 loc) · 1.73 KB
/
index.list2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Item Reordering Example</title>
<style>
/* Add some basic styling for the lists */
ul {
list-style: none;
padding: 0;
margin: 0;
border: 1px solid #ccc;
}
li {
padding: 10px;
border-bottom: 1px solid #eee;
cursor: pointer;
}
</style>
</head>
<body>
<h2>Available Services</h2>
<ul id="availableList">
<li draggable="true">Car Wash</li>
<li draggable="true">Wax</li>
<li draggable="true">Vacuum</li>
<li draggable="true">Polish</li>
<li draggable="true">Drying</li>
</ul>
<h2>Selected Services</h2>
<ul id="selectedList"></ul>
<script>
// Get references to the lists
const availableList = document.getElementById("availableList");
const selectedList = document.getElementById("selectedList");
// Add a drop listener to the selectedList
selectedList.ondragover = (event) => {
event.preventDefault();
};
selectedList.ondrop = (event) => {
event.preventDefault();
const service = event.dataTransfer.getData("text/plain");
const listItem = document.createElement("li");
listItem.textContent = service;
selectedList.appendChild(listItem);
};
// Add a dragstart listener to the availableList items
availableList.addEventListener("dragstart", (event) => {
event.dataTransfer.setData("text/plain", event.target.textContent);
});
</script>
</body>
</html>