www/js/grocery.js
// Define function to add tasks to list
Define function to add tasks to list
Define function to add tasks to list
function addgroceryItem(){
		if($('input').val().trim() === "") {
			$('.error').fadeIn(200);
			} else {
			$('.error').hide();
			var $groceryItem = $('input').val(); 
			var $newListItem = $('<li class="groceryItem">' + $groceryItem + '<span>' + 
			'<a href="#" class="check">' + '<i class="fa fa-check fa-lg"></i>' + '</a>' +
			'<a href="#" class="delete-groceryItem">' + '<i class="fa fa-trash-o fa-lg"></i>' + '</a>' + 
			'</span>' + '</li>');
			var $addListItem = $('ul').append($newListItem);
			$newListItem.hide().fadeIn(500);
			$('input').val("").focus();
		}
	}
function addgroceryItem ( ) { if ( $ ( 'input' ) . val ( ) . trim ( ) === "" ) { $ ( '.error' ) . fadeIn ( 200 ) ; } else { $ ( '.error' ) . hide ( ) ; var $groceryItem = $ ( 'input' ) . val ( ) ; var $newListItem = $ ( '<li class="groceryItem">' + $groceryItem + '<span>' + '<a href="#" class="check">' + '<i class="fa fa-check fa-lg"></i>' + '</a>' + '<a href="#" class="delete-groceryItem">' + '<i class="fa fa-trash-o fa-lg"></i>' + '</a>' + '</span>' + '</li>' ) ; var $addListItem = $ ( 'ul' ) . append ( $newListItem ) ; $newListItem . hide ( ) . fadeIn ( 500 ) ; $ ( 'input' ) . val ( "" ) . focus ( ) ; } }
Define function to add tasks to list
Define function to add tasks to list
// Show error message // Hide error message // Get input value // Create new list item // Add list item to end of list // Hide list item before fading it into view // Refocus input box for next task