Skip to content

Instantly share code, notes, and snippets.

@amitkrishna
Created August 16, 2020 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitkrishna/2ad0270728271eda516112ffde49d28b to your computer and use it in GitHub Desktop.
Save amitkrishna/2ad0270728271eda516112ffde49d28b to your computer and use it in GitHub Desktop.
Onemonth JS for Todo List
$(document).ready(function () {
// YOUR CODE HERE!
$(".add-items").submit(function ( $event ){
$event.preventDefault();
var item = $("#todo-list-item").val();
console.log($("#todo-list-item").val());
console.log(typeof(item));
console.log(typeof(item.val));// undefined
if (Boolean(item.val)) {// run only if condition is true
console.log(Boolean(item.val));// gets the value of the item
console.log(typeof(item));
console.log("Hit");
$("#list-items").append("<li><input type='checkbox'/>" + item + "<a class='remove'>x</a></li>");
$("#todo-list-item").val("");
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment