Notes

jQuery vs. JavaScript

Edit on GitHub

JavaScript

jquery = $

jquery.load('text.html') is the same as $.load('text.html')

Selecting an element by id

Javascript:

1document.getElementById('#jumbo')

jQuery:

1$('#jumbo')

Hiding an element

Javascript:

1document.getElementById('#load').style.display = 'none';

jQuery:

1$('#load').hide();

Inserting HTML

Javascript:

1var text = "hello there!"
2document.getElementById('#page').innerHTML = text;

jQuery:

1var text = "hello there!"
2$('#page').html(text);

Loops

Javascript:

1for (i = 0, i < items.length, i++) {};

jQuery:

1$.each(array, function(i, item)){};

Making an AJAX request

Javascript:

 1xhr = new XMLHttpRequest ();
 2xhr.onreadystatechange = function () {
 3    if (xhr.readyState === 4) {
 4        if (xhr.status === 200) {
 5        document.getElementById('#ajax').innerHTML = xhr.responseText;
 6        }
 7    }
 8};
 9xhr.open('GET','sidebar.html');
10xhr.send();

jQuery:

1$('#ajax').load('sidebar.html');