How do I get my unordered list items counter to work in jquery?

How do I get my unordered list items counter to work in jquery?


Hello there!! I created a to do list with a delete button on the right side of each list item. 
When you type an entry it goes into the ul tag listing everything. 

How do I get the " counter " of my unordered list items to dynamically reflect both added and deleted items from my " to do list "?
I basically need a numeric value displayed in my id called " counter ".

I have been working on this for a few days and I just do not know what to do. 
Maybe there is something I am over looking that is so simple.

Need help asap please.

  1. ==============================================================

  2. <!-- /-------------// HTML CODE STARTS HERE //-------------/ -->

  3.     <title>Random Task List</title> 
  4. <h1>todo list</h1>
  5.      <label><input type="text" id="enter_task" placeholder="Add items to list"></label>
  6.     <input type="submit" id="add" value="Add">
  7.     <p>
  8.         <ul id="todo_list">
  9.         </ul>
  10.     </p>
  11.     <p>There are &nbsp;<span id="counter"></span>&nbsp;items in list.</p>

  12. <!-- /------------// JAVASCRIPT - JQUERY //---------------/ --><script>

  13.   function enter_task () {
  14.         var text = $('#enter_task').val();
  15.         $('#todo_list').append('<li>'+ text + '<input type="submit" class="done delete" value="Delete">' +'</li>');
  16. };

  17. /*
  18. $('#todo_list').on('click', '.edit', function(){
  19.     $(this).parent().attr('contenteditable','true');
  20. });
  21. */

  22. $('#todo_list').on('click', '.delete',function(){
  23.     $(this).parent().remove();
  24. });

  25. $(function() {
  26.     $('#add').on('click', enter_task);
  27. });


  28. // This BELOW is what I wanted to do but it is not working at all.

  29. /*

  30. var todo_list = document
  31. .getElementsByIdName('todo_list');

  32. $('#add').click(function(){
  33.     //$('#todo_list').appendTo('counter');
  34.     $('#counter').text('There are now ' + todo_list.length + ' listed elements.');
  35. });
  36.     
  37. */