I'm having some issues removing list items upon click after using jquery to add the list items. If I had to guess why this is happenings, it's because jquery might be looking at my original HTML document and not the updated one after adding list items? Either way, I can't figure out how to fix it.
Here is my HTML:
<form>
        <div>
            <label for="todo">I need to:</label>
            <input type="text" id="todo" />
        </div>
        <button id ="add" type="button">Add to your to-do list!</button>
</form>
<ul>
</ul>
And my jQuery:
$(document).ready(function() {
    $('#add').click(function() {
        var item = $('#todo')
        $('ul').prepend("<li>"+item.val()+"</li>");
    });
        $('li').click(function() {
        $(this).remove();
    });
});
 
    