Bug with the editor


#1

Not sure if its just my computer but I ended up crashing the tab multiple times by making a mistake on my entry and entering this

$(document).ready(function(){
$($)

});

As soon as i add the dollar sign inside the () it crashes. I am on lessor 11/14 of modifying html elements in the JQuery lessors.


#2

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:

  1. Do not use a jQuery reference as a selector (nothing with $ in the name)
  2. 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.

For instance,

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.

$('#button').click(function(){
    var toAdd = $input.val();
    $('.list').append('<div class="item">' + toAdd + '</div>');
});