jQuery collections

When you use jQuery to find elements, jQuery returns back a jQuery collection object:
var $heading = $('h1');
It is common practice to start variable names like that with a $ sign to show that they're storing jQuery collection objects. That helps distinguish them from variables that store DOM nodes.
If you'd like to retrieve the DOM node out of a jQuery object, then you can treat the jQuery object like an array and use bracket notation:
var heading = $heading[0];
If you'd like to turn a DOM node into a jQuery object, you can pass it into the jQuery function:
var $heading = $(heading);

Looping through collections

If you'd like to loop through multiple elements in a collection, you can use a normal for loop or jQuery's each():
    $("p").each(function(index, element) { 
        $(elem).text( $(element).text() + "!!"); 
When you call the each() function, you must pass a 'callback function' to it. jQuery will then call that callback function for each element in the collection, and it will pass the current index and element to the function.
jQuery will also set the context of the function to the current element, which means you can reference the element with the this keyword:
    $("p").each(function() { 
        $(elem).text( $(this).text() + "!!");