Tsallaka zuwa abun ciki
Justice Tech School

Project: Todo List

Add and remove items with delegation.

Example
$("#add").on("click", function () {
  var t = $("#text").val().trim();
  if (t) $("#list").append("<li>" + $("<i>").text(t).html() + "</li>");
  $("#text").val("");
});
$("#list").on("click", "li", function () { $(this).remove(); });

Exercise

Escape text.

$("<i>").text(t).()

Quiz Test

Why escape user text?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.