a JavaScript library

write less, do more.

makes it easy

download

http://jquery.com/download
to use jQuery from a CDN, just reference the jQuery file in the script tag directly from the CDN domain

basics

jQuery() function

heavily overloaded
four different ways to invoke it

selectors

  
  $("#myDiv");
  $(".myClass");
  $("tr:first");
  $("div:has(p)");
  $("td:parent");
  $("td:empty");
  ...
  
  
http://api.jquery.com/category/selectors

manipulation

  
  $("#myDiv").addClass("myClass");
  $("#myDiv").removeClass("myClass");
  $(".inner").append("<span>Test</span>");
  $(".inner").attr('id', 'newId');
  $("#myDiv").css('border', '1px solid red');
  $("#myDiv").html();
  ...
  
  
http://api.jquery.com/category/manipulation

events

  
  $("#myDiv").on("click", function() {
    console.log($(this).text());
  });

  $(".myClass").trigger("click");
  ...
  
  
http://api.jquery.com/category/events

effects

  
  $("#myDiv").fadeIn();
  $(".target").show();
  $(".target").hide();
  $("#someDiv").slideDown(500);
  $(".target").toggle();
  ...
  
  
http://api.jquery.com/category/effects