Skip to content

Birg0010/To-do-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

To-do-list

<title>To-Do List App</title>

To-Do List

Add Task
    <script src="script.js"></script> document.addEventListener('DOMContentLoaded', function() { const taskForm = document.getElementById('task-form'); const taskInput = document.getElementById('task-input'); const taskList = document.getElementById('task-list');
    taskForm.addEventListener('submit', function(e) {
        e.preventDefault();
        const taskText = taskInput.value.trim();
        if (taskText !== '') {
            addTask(taskText);
            taskInput.value = '';
        }
    });
    
    taskList.addEventListener('click', function(e) {
        if (e.target.classList.contains('delete')) {
            e.target.parentElement.remove();
        } else if (e.target.tagName === 'LI') {
            e.target.classList.toggle('completed');
        }
    });
    
    function addTask(taskText) {
        const li = document.createElement('li');
        li.appendChild(document.createTextNode(taskText));
    
        const deleteBtn = document.createElement('button');
        deleteBtn.className = 'delete';
        deleteBtn.appendChild(document.createTextNode('X'));
        li.appendChild(deleteBtn);
    
        taskList.appendChild(li);
    }
    

    }); body { font-family: Arial, sans-serif; background: #f4f4f4; display: flex; justify-content: center; align-items: center; height: 100vh; }

    .container { background: white; padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); width: 300px; }

    h1 { text-align: center; }

    form { display: flex; justify-content: space-between; margin-bottom: 20px; }

    form input { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 3px; }

    form button { padding: 10px; background: #5cb85c; color: white; border: none; border-radius: 3px; cursor: pointer; }

    form button:hover { background: #4cae4c; }

    ul { list-style: none; padding: 0; }

    ul li { background: #f9f9f9; margin-bottom: 10px; padding: 10px; border: 1px solid #ddd; border-radius: 3px; display: flex; justify-content: space-between; }

    ul li.completed { text-decoration: line-through; color: #888; }

    ul li button { background: #d9534f; color: white; border: none; border-radius: 3px; cursor: pointer; }

    ul li button:hover { background: #c9302c; }

    About

    No description, website, or topics provided.

    Resources

    Stars

    0 stars

    Watchers

    1 watching

    Forks

    Releases

    No releases published

    Packages

     
     
     

    Contributors