jQuery QuickRef

// running code when the page loads
$(document.ready(function(){
  // code goes here
});
 
// prevent caching ajax requests
$.ajaxSetup({
	cache: false
});
 
// access the nth object (!as a jQuery object!)
$('div').eq(0)
$('div:eq(0)')
 
// access the actual DOM element
$('div')[0]
$('div').get(0)
 
// chaining
$('div').hide().text('new content').addClass('updatedContent').show()
 
// multiple selectors
$('selector1, selector2, selector3').length
 
// passing DOM elements in place of selectors
$(document.getElementsByTagName('a')).length
 
// second parameter is context (note that you can also use XHR request as context)
$('input', document.forms[0]).length
 
// filter - filters only among the current selection
$('a').filter('.external').length
 
// find - looks for elements below the selection
$('p').find('em').length
 
// use end() to go back to previous selections (follow markers from end() calls)
$('p').filter('middle').find('span').end().end() // <<<--- if we did something here it would be on the p's
//                ^--------------------|
// ^-----------------------------------------|
 
// andSelf() includes current selection with previous
$('div').find('p').andSelf().css('border', '1px solid')
 
// prev(), next(), parent(), children(), nextAll(), prevAll()
$('li:eq(3)').prev()                      // <<<--- element at eq(2)
$('li:eq(3)').next()                      // <<<--- element at eq(4)
$('li:eq(3)').parent()                    // <<<--- ul or ol element holding the li's
$('li:eq(3)').parent().children()         // <<<--- all li's in this list
$('li:eq(3)').parent().children(':last')  // <<<--- the last li in this list
$('li:eq(3)').nextAll()                   // <<<--- all elements following eq(4)
$('li:eq(3)').prevAll()                   // <<<--- all elements before eq(4)
 
 
// trim whitespace from ends of a string value
$.trim('  some string   ')
 
// show the value of the selected option in an input radio set
$('input[name="somename"]:checked').val()
 
// create html elements and add them to the page
// see also: append(), prepend(), prependTo(), after(), before(), insertAfter(), insertBefore()
// wrap(), wrapAll(), wrapInner()
$('<p><a>jQuery</a></p>').find('a').attr('href', 'http://www.jquery.com').end().appendTo('body')
 
// remove html elements from the page
$('a.someclass').remove()
 
// replacing elements
$('span.original').replaceWith('<span>new</span>')
$('<span>new</span>').replaceAll('span.original')
 
// cloning elements
$('span.someclass').clone().appendTo('body')
 
// cloning elements, including events (passing true to clone())
// notice that this one adds a clone of a button, then removes the original
$('button:first').clone(true).appendTo('body').end().end().remove()

Notes