I want to make a list that you can add to, such as a grocery or todo list using jQuery's .append() and/or .prepend(). Is this possible? Or is Append()/prepend() not able to add text inputs?
I tried
HTML:
<input type="text" id="append">
<input type="submit" value="add after" id="append-to">
<ul id="grocery-list">
<li>apples</li>
</ul>
JS/JQuery:
$('#append-to').on('click', function() {
$('#grocery-list').append("<li>$('#append')</li>");
});
Once submit is clicked, the input's text should be appended to the bottom of the list.
Instead, the string JQuery value "$('#append')" is added. The value of the text input is what should be added.
TLDR: if I type "milk" and hit submit, milk isn't added to the list. but "$('#append')" is added