Simple HTML To-Do List
$(function() {
$("#add").on("click", function() {
var val = $("input").val();
if(val !== '') {
var elem = $("<li></li>").text(val);
$(elem).append("<button class='rem'>X</button>");
$("#mylist").append(elem);
$("input").val("");
$(".rem").on("click", function() {
$(this).parent().remove();
});
}
});
});
<!DOCTYPE html>
<html>
<head>
<title>My To-Do List</title>
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
</head>
<body>
<h1>My To-Do List</h1>
<input type="text" placeholder="New item" />
<button id="add">Add</button>
<ol id="mylist"></ol>
</body>
</html>
h1 {
color: #1abc9c;
}
.rem {
margin-left: 5px;
background-color: white;
color: red;
border: none;
cursor: pointer;
}