Sascha Schulz
2023-04-05 616baa176c724735fadea8b15729145c16926613
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
<!DOCTYPE html>
<html lang="de">
    <head>
        <meta charset="UTF-8">
        <title>todo</title>
        <style>
            button {
                border: 1px solid black;
                border-radius: 5px;
            }
 
            #list {
                background-color: lightgoldenrodyellow;
            }
        </style>
    </head>
    <body>
        <input><button>add</button>
 
        <div id="list"></div>
 
        <script>
            const input = document.querySelector("input");
            const button = document.querySelector("button");
            const list = document.querySelector("#list");
 
            button.addEventListener("click", (event) => {
                const div = document.createElement("div");
 
                div.innerText = input.value;
 
                list.appendChild(div);
 
                input.value = "";
            });
        </script>
    </body>
</html>