JavaScript/HTML/CSS Hilfe

MrOsmo

Mitglied
Hallo zusammen!

Ich habe angefangen eine ToDoListe zu machen und bin schon fast fertig. Allerdings muss ich noch zwei Buttons fertigen und ich weiss nicht wie. Das erste Button ist "Delete All", dieser sollte alle Aufgaben (Aufgaben der ToDoListe) löschen. Das zweite ist "Change Status", dieser sollte, sofort alle Aufgaben wegstreichen oder zeigen dass diese Aufgaben gemacht worden sind. Ich hoffe auf eure Hilfen!

Bin schon richtig müde, und muss die Aufgaben schon bis morgen abschicken..

Dankeschön im Voraus!

LG
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Google Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">


    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <link rel="stylesheet" href="./style.css">
    <title>To Do List</title>
</head>
<body>


    <header>
        <h1>My Tasks</h1>
    </header>
    <form action="">
       <div class="inputs">
        <input type="text" class="todo-input">
        <input type="date" class="todo-input-two">
       </div>
        <button class="todo-button" type="submit">
            <i class="fas fa-plus-circle fa-lg"></i>
        </button>
        <div class="select">
            <select name="todos" class="filter-todo">
                <option value="all">All</option>
                <option value="completed">Completed</option>
                <option value="incomplete">Incomplete</option>
            </select>
        </div>
    </form>


    <div class="todo-container">
        <ul class="todo-list"></ul>
    </div>


    <div class="deleteAll">
      <button>Delete All</button>
      <button>Change Status</button>
    </div>


    <script src="./script.js"></script>
    
</body>
</html>
CSS:
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}


body {
  background-image: linear-gradient(45deg, rgb(20, 222, 124) 0%, rgb(20, 222, 124) 21%,rgb(25, 190, 119) 21%, rgb(25, 190, 119) 37%,rgb(30, 158, 113) 37%, rgb(30, 158, 113) 46%,rgb(35, 126, 108) 46%, rgb(35, 126, 108) 53%,rgb(39, 94, 103) 53%, rgb(39, 94, 103) 59%,rgb(44, 62, 97) 59%, rgb(44, 62, 97) 77%,rgb(49, 30, 92) 77%, rgb(49, 30, 92) 100%);
  background-repeat: no-repeat;
  height: 1220px;
  color: white;
  font-family: "Poppins", sans-serif;
  min-height: 100vh;
}


header {
  font-size: 1.5rem;
}


header,
form {
  min-height: 20vh;
  display: flex;
  justify-content: center;
  align-items: center;
}


.inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}


form input,
form button {
  padding: 0.5rem;
  padding-left: 1rem;
  font-size: 1.8rem;
  border: none;
  background: white;
  border-radius: 2rem;
}


form button {
  color:  #311E5C;
  background: white;
  cursor: pointer;
  transition: all 0.3 ease;
  margin-left: 0.5rem;
}


form button:hover {
  color: white;
  background: #311E5C;
}


.fa-plus-circle {
  margin-top: 0.3rem;
  margin-left: -8px;
}


.todo-container {
  display: flex;
  justify-content: center;
  align-items: center;
}


.todo-list {
  min-width: 30%;
  list-style: none;
}


.todo {
  margin: 0.5rem;
  padding-left: 0.5rem;
  background: white;
  color: black;
  font-size: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: 0.5s;
  border-radius: 2rem;
}


.todo li {
  flex: 1;
}


.trash-btn,
.complete-btn {
  color: white;
  border: none;
  padding: 1rem;
  cursor: pointer;
  font-size: 1.5rem;
}


.complete-btn {
  background: #311E5C;
}


.trash-btn {
  border-top-right-radius: 1.75rem;
  border-bottom-right-radius: 1.75rem;
  background: #275E67;
}


.todo-item {
  padding: 0rem 0.5rem;
}


.fa-trash,
.fa-check-circle {
  pointer-events: none;
}


.completed {
  text-decoration: line-through;
  opacity: 0.5;
}


.slide {
  transform: translateX(10rem);
  opacity: 0;
}


select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  outline: none;
  border: none;
}


.select {
  margin: 1rem;
  position: relative;
  overflow: hidden;
  border-radius: 50px;
}


select {
  color:#311E5C;
  width: 10rem;
  height: 3.2rem;
  cursor: pointer;
  padding: 1rem;
}


.select::after {
  content: "\25BC";
  position: absolute;
  background:#311E5C;
  top: 0;
  right: 0;
  padding: 1rem;
  pointer-events: none;
  transition: all 0.3s ease;
}


.select:hover::after {
  background: white;
  color: #311E5C;
}


.deleteAll {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-left: -150px;
  margin-top: 35px;
}


.deleteAll button {
  padding: 0.5rem;
  padding-left: 1rem;
  font-size: 30px;
  border: none;
  background: white;
  border-radius: 2rem;
  color: #311E5C;
  text-transform: uppercase;
  cursor: pointer;
}


.deleteAll button:hover {
  color: white;
  background-color: #311E5C;
}
Javascript:
const todoInput = document.querySelector(".todo-input");
const todoInputTwo = document.querySelector(".todo-input-two")
const todoButton = document.querySelector(".todo-button");
const todoList = document.querySelector(".todo-list");
const filterOption = document.querySelector(".filter-todo");
const deleteAllTodos = document.querySelector(".deleteAll button")


document.addEventListener("DOMContentLoaded", getLocalTodos);
todoButton.addEventListener("click", addTodo);
todoList.addEventListener("click", deleteCheck);
filterOption.addEventListener("change", filterTodo);


function addTodo(event) {
    event.preventDefault();
    const todoDiv = document.createElement("div");
    todoDiv.classList.add("todo");
    const newTodo = document.createElement("li");
    newTodo.innerText = `${todoInput.value}, Date: ${todoInputTwo.value}`;
    newTodo.classList.add("todo-item");
    todoDiv.appendChild(newTodo);
+
    saveLocalTodos(todoInput.value);
    
    const completedButton = document.createElement("button");
    completedButton.innerHTML = '<i class="fas fa-check-circle"></li>';
    completedButton.classList.add("complete-btn");
    todoDiv.appendChild(completedButton);


    const trashButton = document.createElement("button");
    trashButton.innerHTML = '<i class="fas fa-trash"></li>';
    trashButton.classList.add("trash-btn");
    todoDiv.appendChild(trashButton);
    
    todoList.appendChild(todoDiv);
    todoInput.value = "";
}


function deleteCheck(e) {
    const item = e.target;


    if(item.classList[0] === "trash-btn") {
        const todo = item.parentElement;
        todo.classList.add("slide");


        removeLocalTodos(todo);
        todo.addEventListener("transitionend", function() {
            todo.remove();
        });
    }


    if(item.classList[0] === "complete-btn") {
        const todo = item.parentElement;
        todo.classList.toggle("completed");
    }
}


function filterTodo(e) {
    const todos = todoList.childNodes;
    todos.forEach(function(todo) {
        switch(e.target.value) {
            case "all":
                todo.style.display = "flex";
                break;
            case "completed":
                if(todo.classList.contains("completed")) {
                    todo.style.display = "flex";
                } else {
                    todo.style.display = "none";
                }
                break;
            case "incomplete":
                if(!todo.classList.contains("completed")) {
                    todo.style.display = "flex";
                } else {
                    todo.style.display = "none";
                }
                break;
        }
    });
}


function saveLocalTodos(todo) {
    let todos;
    if(localStorage.getItem("todos") === null) {
        todos = [];
    } else {
        todos = JSON.parse(localStorage.getItem("todos"));
    }
    todos.push(todo);
    localStorage.setItem("todos", JSON.stringify(todos));
}


function getLocalTodos() {
    let todos;
    if(localStorage.getItem("todos") === null) {
        todos = [];
    } else {
        todos = JSON.parse(localStorage.getItem("todos"));
    }
    todos.forEach(function(todo) {
        const todoDiv = document.createElement("div");
        todoDiv.classList.add("todo");
        const newTodo = document.createElement("li");
        newTodo.innerText = todo;
        newTodo.classList.add("todo-item");
        todoDiv.appendChild(newTodo);


        const completedButton = document.createElement("button");
        completedButton.innerHTML = '<i class="fas fa-check-circle"></li>';
        completedButton.classList.add("complete-btn");
        todoDiv.appendChild(completedButton);


        const trashButton = document.createElement("button");
        trashButton.innerHTML = '<i class="fas fa-trash"></li>';
        trashButton.classList.add("trash-btn");
        todoDiv.appendChild(trashButton);


        todoList.appendChild(todoDiv);
    });
}


function removeLocalTodos(todo) {
    let todos;
    if(localStorage.getItem("todos") === null) {
        todos = [];
    } else {
        todos = JSON.parse(localStorage.getItem("todos"));
    }



  deleteAllTodos.addEventListener("click", removeAllTodos);



    const todoIndex = todo.children[0].innerText;
    todos.splice(todos.indexOf(todoIndex), 1);
    localStorage.setItem("todos", JSON.stringify(todos));
}
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
M Javascript: HTML-Datei erstellen und auf Festplatte speichern HTML / CSS 8
M HTML-Code einer fremden Webseite auslesen - geht das mit Javascript HTML / CSS 19
A Nur bestimmte Zeichen in HTML input Feld erlauben (JavaScript) HTML / CSS 11
H javascript - html Beispiel LQH, verwirklichung HTML / CSS 1
J Mit Javascript eine Textdatei auslesen... HTML / CSS 28
S jqmath in javascript einbinden HTML / CSS 3
M Javascript: Farbkontrast überprüfen auf einer Webseite HTML / CSS 14
M Javascript: CSS Parsen um herauszufinden ob relativer Schriftgrößen verwendet werden HTML / CSS 23
S Sicherheitsaspekt JavaScript HTML / CSS 3
M Webservice per Javascript ansprechen HTML / CSS 5
G php in javascript einbinden HTML / CSS 13
E Javascript/ Eventlistener ohne click? HTML / CSS 2
J JavaScript Woerter erkenen HTML / CSS 4
C Eclipse und Javascript full autocomplete? HTML / CSS 1
A DragDrop mehrerer Shapes im SVG per Javascript? HTML / CSS 0
M Javascript Tastatureingabe HTML / CSS 2
B javascript ausgabe in Text HTML / CSS 2
E Javascript Status Abfrage HTML / CSS 7
J Javascript im DOM einer Webseite ändern HTML / CSS 1
P JavaScript var an bean Setter übergeben HTML / CSS 2
Z Erste Website CSS3 HTML5 Javascript Jquery - Kritik HTML / CSS 3
P RSS FEED/ JSON/ Filter By Date/ Handlebars / Javascript HTML / CSS 0
B Externes Suchfeld - Javascript. REST? HTML / CSS 0
S JavaScript und Ajax Erfahrene Gesucht!!!! HTML / CSS 0
V Javascript Adobe Acrobat XI Pro Formular Dropdown-Liste -> vorbelegte Checkboxen HTML / CSS 1
0 Javascript Leaflet Marker Popup mit Adresse HTML / CSS 1
V externes CSS in html HTML / CSS 6
V Horizontales Scroll-HTML HTML / CSS 2
V Variablenname in meinem HTML-Objekt HTML / CSS 3
Avalon Löschen Button HTML HTML / CSS 39
RashAGhul Html/Css Placeholder positionierung ändern HTML / CSS 6
PhilipMJNE Hilfe bei HTML und CSS! HTML / CSS 12
PhilipMJNE CSS in HTML via Link einbinden PROBLEM ! HTML / CSS 22
VPChief HTML Bei bestimmter eingabe in textfeld neu HTML Seite öffnen HTML / CSS 6
B Bilder aus Server in HTML anzeigen HTML / CSS 5
B Zeit für Doppelklick messen (HTML/JS) HTML / CSS 3
U Html Funktion Java Funktion zuweisen HTML / CSS 2
D Daten von einer HTML Datei auf eine andere HTML Datei bekommen HTML / CSS 2
E HTML DOM HTML / CSS 1
Dimax HTML bei button click Formular an php senden aber andere seite öffnnen HTML / CSS 23
Dimax Mehrere css Dateien in eine HTML Seite einbinden HTML / CSS 3
Dimax Variable vom Get Request in HTML abfangen HTML / CSS 9
A Mit Modal (Bootstrap) eine html Seite anzeigen, die von id abhängig ist HTML / CSS 0
D HTML- Formulare an den Server senden HTML / CSS 7
S Quiz mit HTML/PHP erstellen HTML / CSS 3
W Keylistener Applet in Html HTML / CSS 9
S HTML Datei per E-Mail versenden HTML / CSS 3
K Html Programmieroberfläche einbinden (java) HTML / CSS 1
_Andi84 Unfertige HTML Ersetzungsfunktion HTML / CSS 1
T [JS] Extrahiere werte aus HTML Tabelle (td) aber nur bestimmten Teil HTML / CSS 5
K Verständnis von HTML/CSS & JScript HTML / CSS 2
Pataraca mit HTML auf php zugreifen HTML / CSS 1
I zugehörige HTML bzw. PHP Datei in den Entwicklertools finden HTML / CSS 3
D Hilfe bei erster Html-Aufgabe (Rahmen) HTML / CSS 6
KaffeeFan HTML Text rotieren HTML / CSS 2
K How to create Html tables for java parser objects? HTML / CSS 2
EisKaffee HTML interner Link soll neues Fenster aufmachen HTML / CSS 2
I Menü, Header, Content ausgliedern aus einer HTML Seite HTML / CSS 2
G HTMl Tabellen-Zelle zeilen oder Höhe begrenzen HTML / CSS 1
O HTML/CSS doppeltes DropDown Menu HTML / CSS 1
Blueskull Brauche Hilfe bei Passwortschutz und automatische Weiterleitung an Website. Bitte..... Brauche Hilfe! HTML / CSS 4
Skeezycw brauche hilfe weiß nicht was ich falsch mache HTML / CSS 4
L Hilfe bei Bildskalierung mit CSS HTML / CSS 11
Zrebna Benötige Hilfe mit JS unter Verwendung von nodes.js HTML / CSS 2
V Hilfe: Planlos HTML / CSS 0
S ImageSlider anpassen... Hilfe!!! HTML / CSS 4
P Hilfe bei Jquery script HTML / CSS 2

Ähnliche Java Themen

Neue Themen


Oben