Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
./script.js
./style.css
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
13 changes: 10 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@
<head>
<title>Todo List</title>
<link rel="stylesheet" type="text/css" href="style.css">

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<h1>Todo List</h1>
<form id="todoForm">
<input type="text" id="todoInput" placeholder="Enter a task">
<button type="submit">Add</button>
<form id="todoForm" onsubmit="addItems(event)">
<input type="text" id="todoInput" placeholder="Enter a task" class="inputStyle">
<button type="submit" class="btn btn-primary">Add</button>
</form>
<ul id="todoList"></ul>
</div>

<script src="script.js"></script>

<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-fbbOQedDUMZZ5KreZpsbe1LCZPVmfTnH7ois6mU1QK+m14rQ1l2bGBq41eYeM/fS" crossorigin="anonymous"></script>

</body>
</html>
21 changes: 21 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function addItems(event) {
event.preventDefault();
let item = document.getElementById("todoInput");
let ul = document.getElementById("todoList")

let br = document.createElement("br");
let newLi = document.createElement("li");
let newCheck = document.createElement("input");
newCheck.type = "checkbox";

if (item.value === "") {
alert("Enter your TO-Do please!")
item.focus();
return false;
} else{
ul.appendChild(newCheck);
ul.appendChild(newLi);
newLi.innerHTML = item.value;
ul.appendChild(br);
}
}
15 changes: 15 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
body{
margin-top: 70px !important;
margin-left: 40% !important;
}
label{
margin: 5px;
}
.inputStyle{
margin-top: 20px;
width: 30%;
}
li{
display: inline;
padding: 10px;
}