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>Notes App</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
        }
        #notes-container {
            width: 300px;
            margin-top: 20px;
        }
        .note {
            background-color: #f4f4f4;
            margin: 10px 0;
            padding: 10px;
            border-radius: 5px;
            display: flex;
            justify-content: space-between;
        }
        .delete-button {
            cursor: pointer;
            color: #ff0000;
        }
    </style>
</head>
<body>
    <div id="notes-container">
        <div class="note">
            <span>Note 1</span>
            <span class="delete-button" onclick="deleteNote(this)">X</span>
        </div>
        <div class="note">
            <span>Note 2</span>
            <span class="delete-button" onclick="deleteNote(this)">X</span>
        </div>
    </div>
    <div>
        <textarea id="newNote" placeholder="Type your note here"></textarea>
        <button onclick="addNote()">Add Note</button>
    </div>
    <script>
        function addNote() {
            var noteText = document.getElementById('newNote').value;
            if (noteText.trim() !== '') {
                var notesContainer = document.getElementById('notes-container');
                var noteDiv = document.createElement('div');
                noteDiv.className = 'note';
                noteDiv.innerHTML = '<span>' + noteText + '</span>' +
                                    '<span class="delete-button" onclick="deleteNote(this)">X</span>';
                notesContainer.appendChild(noteDiv);
                document.getElementById('newNote').value = '';
            }
        }
        function deleteNote(element) {
            var noteDiv = element.closest('.note');
            noteDiv.remove();
        }
    </script>
</body>
</html>
Leave a Comment