There should be no reason to use a jQuery object as a selector. If it has a $ in the variable name, it may already be a jQuery object, so doesn't need to be queried again. It has all the methods.
The problem can be solved in one of two ways:
- Do not use a jQuery reference as a selector (nothing with $ in the name)
- Add a syntax error to your code, such as
else at the top of your code. This will throw an error and terminate the auto-run. Remove the error when ready to test your code.
var $input = $('input[name=checkListItem]');
$input is now a jQuery object reference, and has access to the object context so has all the methods at its disposal.
var toAdd = $input.val();
$('.list').append('<div class="item">' + toAdd + '</div>');