diff --git a/index.html b/index.html new file mode 100644 index 0000000..03ce864 --- /dev/null +++ b/index.html @@ -0,0 +1,16 @@ + + + + + + + + +
+

Gitt Going

+ + + +
+ + \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..42057f3 --- /dev/null +++ b/script.js @@ -0,0 +1,39 @@ +// Load todos from localStorage at startup +document.addEventListener('DOMContentLoaded', function() { + var todos = JSON.parse(localStorage.getItem('todos')) || []; + todos.forEach(addItem); +}); + +document.getElementById('add-todo').addEventListener('click', function() { + var value = document.getElementById('todo-input').value; + if (value) { + addItem(value); + document.getElementById('todo-input').value = ''; + saveTodos(); + } +}); + +function addItem(text) { + var list = document.getElementById('todo-list'); + + var item = document.createElement('li'); + item.innerText = text; + + var deleteButton = document.createElement('button'); + deleteButton.innerText = 'Delete'; + deleteButton.addEventListener('click', function() { + list.removeChild(item); + saveTodos(); + }); + + item.appendChild(deleteButton); + + list.appendChild(item); +} + +function saveTodos() { + var todos = Array.from(document.getElementById('todo-list').children).map(function(item) { + return item.innerText.replace('Delete', ''); + }); + localStorage.setItem('todos', JSON.stringify(todos)); +} \ No newline at end of file diff --git a/style.css b/style.css index c69bcc1..3aa0977 100644 --- a/style.css +++ b/style.css @@ -19,7 +19,7 @@ body { #todo-list li { padding: 10px; - border: 1px solid #ddd; + border: 2px solid #ddd; margin-bottom: 10px; position: relative; }