I want to add elements on click event, there is an input text element and when user clicks on add I want to add that as an item to an unordered list. This is simple I prefer to do it with just JS but have to use JQuery. So, basically I want to:
- get value of the input text
- append li item to ul list
- append a label for the li item
- add value from input as text for label.
Here's my code - it's definitely not working but the above 4 steps is what I want to achieved in JQuery:
$(document).ready(function(){
var $add_button = $('#add-item')
var newItem;
var $incompleteTasks = $('#incomplete-tasks');
$add_button.click(function(){
newItem = $('#new-task').val();
// append new item to incomplete tasks ul
$incompleteTasks.append('<li>appended</li>')
.append('<label></label>').text(newItem);
});
});