jQuery


Selectors

$('.foo').addClass("foobar");
$('.foo').removeClass("foobar");

Attribute and Style manipulations

$('.foo').attr("new-attr", "new-value");
$('.foo').css("background", "white");

Ajax

$.getJSON('http://resource.json', doSomething);
$.ajax({
    url: 'http://resource.txt',
    dataType: 'text',
    type: 'GET',
    success: doSomething
});

Append and Prepend nodes

$('.foo').append('<div/>');
$('.foo').prepend('<div/>');

Listening to events

$('.foo').on('click', clickHandler);

Removing elements

$('.foo').remove();

Content manipulation

$('.foo').text('Hello World!');
$('.foo').html('<div class="bar">Hello</div>');

inserting a new element after each li element

$('li').after('<li>Item</li>');

obviously .before() works the opposite way. The .empty() function will completely remove all children of an element

$('ul').empty();