<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="assets/css/style.css">
  <link rel="icon" href="https://cdn4.iconfinder.com/data/icons/small-n-flat/24/notepad-512.png" type="image/x-icon" />
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
    integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
  <link href="https://fonts.googleapis.com/css?family=Stylish|Kalam|Permanent+Marker" rel="stylesheet">
  <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
  <title>To Do list</title>
</head>

<body>

  <div id="container">
    <h1></i>To-Do List<span id="toggle-form"><i class="fas fa-pen"></i></span></h1>
    <input type="text" placeholder="Add New Todo">

    <ul>
      <li><span><i class="fas fa-trash"></i></span> Buy Robes</li>
      <li><span><i class="fas fa-trash"></i></span> Fly a car</li>
      <li><span><i class="fas fa-trash"></i></span> Get potions supplies</li>
      <li><span><i class="fas fa-trash"></i></span> Kill Voldemort</li>
      <li><span><i class="fas fa-trash"></i></span> Catch the Snitch</li>


    </ul>

  </div>

  <script src="assets/js/todo.js"></script>
</body>

</html>
h1 {
    background-image: url(https://ih0.redbubble.net/image.298271122.7524/pp,550x550.u1.jpg);
    background-size: cover;
    background-position: center;
    background-color: darkcyan;
    color: white;
    margin: 0;
    padding: 20px 20px;
    font-family: "Stylish";
    text-transform: uppercase;
    font-weight: normal;

}

.fa-pen {
    float: right;
    font-size: 24px;
    margin-top: 5px;
}

li {
    font-family: "Kalam";
    height: 40px;
    background: #fffce6;
    line-height: 40px;
    color: #1C1C1C;

}

li:nth-child(2n) {
    background: #FFF9C4;

}

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

#container {
    margin: 100px auto;
    width: 300px;
    min-height: 200px;
    background-color: #FFF9C4;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
}

.completed {
    color: gray;
    text-decoration: line-through;
}

body {
    font-family: "Averta";
    background-color: #fffef5;
    background-image: url("https://www.transparenttextures.com/patterns/45-degree-fabric-light.png");
    /* This is mostly intended for prototyping; please download the pattern and re-host for production environments. Thank you! */

}

input {
    font-family: "Kalam";
    font-size: 18px;
    padding: 13px 13px 13px 20px;
    background-color: #FFF9C4;
    width: 100%;
    /* box-sizing stops overflowing the field */
    box-sizing: border-box;
    color: darkcyan;
    border: 3px solid rgba(0, 0, 0, 0)
}

input:focus {
    background: white;
    border: 3px solid darkcyan;
    outline: none;
    transition: 0.15s linear;
}

input:first-letter {
    text-transform: uppercase;
}

li span {
    background: #e74c3c;
    height: 40px;
    margin-right: 20px;
    text-align: center;
    color: white;
    width: 0px;
    display: inline-block;
    transition: 0.2s linear;
    opacity: 0;
}


li:hover span {
    width: 40px;
    opacity: 1;
}

::placeholder {
    /* Chrome, Firefox, Opera, Safari 10.1+ */
    color: #B2B2B2;
    opacity: 1;
    /* Firefox */
}

:-ms-input-placeholder {
    /* Internet Explorer 10-11 */
    color: #B2B2B2;
}

::-ms-input-placeholder {
    /* Microsoft Edge */
    color: #B2B2B2;
}
//check off/restore specific Todos by clicking
$("ul").on("click", "li", function () {
    $(this).toggleClass("completed");
});

//click on X to delete Todo
$("ul").on("click", "span", (function (event) {
    //fadeOut separate function call needed since otherwise remove() would occur without waiting out the fadeOut
    $(this).parent().fadeOut(400, function () {
        $(this).remove();
    });
    //to stop events bubbling up to parent li event
    event.stopPropagation();
}))

//add new Todo
$("input[type='text']").keypress(function (event) {
    if (event.which === 13) {
        //using .val() method to pull value of input
        var todoText = $(this).val();
        //clear input
        $(this).val("");
        //create a new li and add to ul
        $("ul").append("<li><span><i class='fas fa-trash'></i></span>" + " " + todoText + "</li>");
    }
});

//hide or display the input field for new Todo
$("#toggle-form").click(function () {
    $("input[type='text']").fadeToggle(200);
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.