Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.2 kB
2
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Note-taking Website</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }

        #noteInput {
            width: 70%;
            padding: 8px;
        }

        #addNoteBtn {
            padding: 8px;
            cursor: pointer;
        }

        #noteList {
            margin-top: 20px;
        }

        .note {
            margin-bottom: 10px;
            padding: 10px;
            border: 1px solid #ccc;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .deleteBtn {
            background-color: #ff6666;
            color: white;
            border: none;
            padding: 5px 10px;
            cursor: pointer;
        }
    </style>
</head>
<body>

    <h1>Note-taking Website</h1>

    <div>
        <input type="text" id="noteInput" placeholder="Enter your note">
        <button id="addNoteBtn" onclick="addNote()">Add Note</button>
    </div>

    <div id="noteList"></div>

    <script>
        function addNote() {
            const noteInput = document.getElementById('noteInput');
            const noteList = document.getElementById('noteList');

            if (noteInput.value.trim() !== '') {
                const noteDiv = document.createElement('div');
                noteDiv.className = 'note';

                const noteText = document.createElement('span');
                noteText.innerText = noteInput.value;

                const deleteBtn = document.createElement('button');
                deleteBtn.className = 'deleteBtn';
                deleteBtn.innerText = 'Delete';
                deleteBtn.onclick = function() {
                    noteList.removeChild(noteDiv);
                };

                noteDiv.appendChild(noteText);
                noteDiv.appendChild(deleteBtn);
                noteList.appendChild(noteDiv);

                noteInput.value = '';
            }
        }
    </script>

</body>
</html>
Leave a Comment