REFS Base API: http://api.jquery.com/ DOM Traversal API: http://docs.jquery.com/DOM/Traversing jquery selectors: http://docs.jquery.com/DOM/Traversing/Selectors Events: http://docs.jquery.com/Events Determine version: jQuery.fn.jquery OR $.fn.jquery or find the scripts tag that loads ".../jquery-*.js". Gotcha: Dots in id references must be \\-escaped like $("a\\.b") Seems to be no support for getting text into system clipboard. Differences from PrototypeJS. Not certain about these yet. * No infrastructure for subclassing. * Methods, including traversal methods, work great with general XML docs in addition to HTML docs. N.b., the $(x) construct is extravagantly overloaded according to http://api.jquery.com/jQuery/ Generally, IF JQuery sees that x is a string that contains . Prevent default callback action by running in your own callback: e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation(); The JQuery instance methods operate on JQuery objects. JQuery objects have a list of 0 or more DOM Elements, and these are what are operated upon by the JQuery instance methods. jo.each(fn(i)...) sets 'this' to each DOM Element in turn, with param i index. (2nd param is element but that's useless since this is === 'this'). USEFUL! to use arrow function: (index, w3cel) => {... jo.length (slightly faster than equivalent jo.size()). Similarly, you can jo[index] to get DOM Elements (jo.get([-]index) is a generalization of jo[index]). .eq vs. .get vs. [] IMPORTANT! ------------------- jo.eq([-]index) just like jo.get() or [i], but returns 1-el jo instead. WTF did I mean by '1-el'? When I do jo.eq(0) it returns the 0th element! Since you can't run JQuery methods directly on a DOM Element, in order to run a JQuery method on DOM elements, you must convert the DOM Elements into 1-element JQuery instances, like $(this). A sad consequence to the fact that selectors may validly generate a 0-element jo, you get no indication at all if you goofed in your selector. API Though instance methods are usually called like $("selector").methName(...), the selector doesn't need to be a string, and the methods really require a JQuery object regardless of how it was instantiated. Therefore I'll write "jo" below to indicate a JQuery object instance. $ The JQuery class. Therefore, those JQuery methods that aren't instance-specific are like $.x(...). I think these are all listed in the API like "jQuery.ajax()". I.e. in code, "$." === "jQuery." $(x).m() are JQuery instance methods since the expression $(x) is a jo. These are chainable, i.e. they return a jo. $.m() are JQuery static/utility methods. $.isPlainObject(obj) test if plain old dictionary object. $.append(...); $.proxy(fn, contextObj); See note below about proxy + bind. $.proxy(contextObj, "targetContextObjFnName"); $.ajax({lostsa: "options",...}); $.get(...) and $.post(...) are wrappers for $.ajax that use positioned parameters instead of a map See AJAX section below. $.each([array] or Object, fn(i, v)) // I value begins at 0 'this' in the fn body is value just like 'v', but unfortunately is always type-converted to an Object, even for strings. Fn method body should return false to short cut iteration. $.support(...) about browser support List.each(fn(indexParam). (During each function invocation, 'this' is the el. (as noted below, most JQuery methods are made to work with element lists). $.contains(container, contained) $.extend(...) merges JS Objects/dictionaries into the 1st one (returns ref to it) $.merge(...) merges JS Arrays $.grep(array, fn) where fn is boolean function(el, index) $.inArray(value, array) like Java array.indexOf(value) $.makeArray(arrayLike) $.is*(thing) just like the PrototypeJS variable/value type tests. POSTNOTE: NO. Much more limited than that. $.map(array|arrayLikefn) fn = newEl function(domEl, index){ // this is Win $.param(obj) encodeURIComponent's each key and vals, then joins then into a single query string. $.trim() just like Java's obj = $.parseJSON(jsonText) jo set manipulations (The jo's keep a history of these so can rewind, etc.) -------------------- jo.ready() NO REASON TO USE THIS. Special and only usable with 'document', so just call $(handler) instead. jo.filter("narrowing selector") jo.not("excluding selector") jo.next(), jo.prev() Next/previous sibling of each jo in set jo.parent(["selector"]) returns 0 or more jo.parents(["selector"]), parentsUntil([s]) ANCESTORS!!!! returns 0 or more jo.closest("selector"[, context]) like parents() but returns 0 or 1 and starts with self jo1.add(jo2) Just like $("sel1, sel2") but lets you use jo instance methods on the two parts, like: $("#top div").first().add($("#olId li").first()) jo.andSelf() Adds (back) previous jo in selection chain. jo.children([selector]) Just like .find() but only for direct children jo.contents() Just like .children() but gets text and comment children also jo.find("selector") Looks within descendants Must do this to get ALL descendants: jo.find("*") jo.end() reverts to set previous to last filter (only useful after doing an op) jo.eq([-]index) generates a 1-element jo with the specified element. jo.first() == jo.eq(0) jo.last() Think like jo.eq(-1) jo.has(jo|"selector") if a descendant of X matches jo.hasClass("className") jo.nextAll(["selector"] jo.nextUntil(["selector"], jo.prevAll(["selector"] jo.prevUntil(["selector"] jo.one(eventType...) Just like bind but will execute once and auto-unbind. jo.siblings() jo.slice(...) like .eq(...) operations insert operations ----------------- jo.html("HTML"); // REPLACES INSIDE of ALL matching els. Always returns jo/jo1. jo.text("text content"); // REPLACES ALL matching els, escaping HTML jo.before("HTML"); inserts above the jo el(s) right before they open jo.prepend("HTML"); inserts inside the jo el(s) right after they open jo.append("HTML"); inserts inside the jo el(s) right before they close jo.after("HTML"); inserts after the jo el(s) right after they close. jo1.appendTo(jo2) Appends each jo1 DOM element to each jo2 element. For already-home jo1 elements, they will be MOVED. For multiple jo2 elements, jo1 elements will be cloned. newJo.*To() and newJo.*Before(), newJo.*After() return the newJo for chaining. Where * == insert/append/prepend. Useful idiom: jo.clone().*To(...) and similar. other operations ---------------- These functions get a plain old DOM element: jo[n], jo.get(n) so can jo[n].id These functions get a JO: jo.eq([-]index), jo.first(), jo.last() so can jo.eq(n).attr("id") jo.toArray() Array of plain old DOM Elements. jo.get() Converts jo elements to a real array of DOM Elements jo.get([-]index) Gets a real DOM Element (superset of jo[index]). jo.detach([selector]) JUST detaches els from doc. jo.remove([selector]) = jo.detach() + jo.empty() + remove it + data + events. jo.removeClass("class1 class2...") jo.removeAttr("attName") jo.addClass("nam"); jo.toggleClass(...) jo.hover(overFn, outFn); jo.css("cssPropName") Returns specified style value OF FIRST EL in jo set Supports both camelBack names and hyphen-ated! !! Does onto support collection shortcuts like "margin"! jo.css("cssPropName", "propVal") or jo.css("cssPropName", fn(i,oldV)) or .css({cssPropName1: v1, cssPropName2: v2,...}); NOT ONLY FIRST! ALWAYS use jo.attr for HTML el attr="x" values; always use jol.prop for HTML el JavaScript prop/members. jo.attr("attrName") Returns attr value OF FIRST EL in jo set jo.attr("attrName", "attrVal") or jo.attr("attrName", fn(i,oldV)) or .attr({attrName1: v1, attr: v2,...}); NOT ONLY FIRST! jo.prop("member") and jo.prop("member", "val"); // corresponding purpose for the .attr functions. jo.text(); // Fetches combined recursive text of ALL matching els. // (strips tags) jo.html(); // getter for the HTML content INSIDE FIRST el in jo set. $("xpath/Selector", xmlNode).text() XML text content of matching XML node(s)? jo.bind() See BINDING below. jo.unbind([eventType[, handler|false]) or jo.unbind(event) eventType may used . namespaces. Last is to unbind self fn from the body. jo.delegate(selector, eventType[, eventData], handler) Just like bind(), but the selector is evaluated as the DOM changes, not just at .delegate() execution time. jo.undelegate(...) jo.live(), jo.die() Just like delegate, but bound to the root of the DOM tree, depending on bubble-up. jo.clone([withDataAndEvents]) deep/recursive jo.data(), jo.data("key"), jo.data("key", val), jo.data({...}). jo.removeData(. JQuery system itself writes _*, "event", and "handle" keys. There are portability concerns. jo.empty() clears all descendants, INCL. text nodes jo.hide([duration][[, easing], finfn]), jo.show(), jo.toggle() // Use following methods to work with numbers instead of the Strings used by // HTMLElement.height, etc. jo.height(), jo.width() of FIRST el in jo set jo.innerHeight(), innerWidth() Padding but not border or margin. jo.outerHeight(), jo.outerWidth() size w/ border jo.outerHeight(tru), jo.outerWidth(true) size w/ margin. SWEET jo.index(...) returns index within a collection (which is set variously) boolean jo.is("selector") if any match jo.load("url", ...) does $.ajax "GET" and writes retrieved content to specd. el. newJo jo.map(fn) fn = newEl function(index, domEl){ // this is domEl...} newJo.replaceAll(olds) oldJo.replaceWith(news) ANIMATION-RELATED http://wayfarerweb.com/animate-example.php jo.animate({targetCssProps}, opts) OR jo.animat(tcp, [durat], [ease], [finifn]) interps. over time across any numerical css value. ANIMATION section below. jo.delay(duration) This effects only things in the animation queue. To delay stuff more generally, queue a function with.queue(fn). jo.queue(fn) Execute a function in the anim queue. 'this' (context) and '$(this)' available in the fn. jo.fade*(...) joslide*(...) jo.scrollLeft(), jo.scrollTop() report scroll positions formJo.serialize() makes a .param() out of named params for the form formElementsJo.serialized() similarly jo.offset() topLeftCoordsObj in doc of FIRST matching El. Since there is no style to position according to doc if there is an intervening non-static element, I don't know how this value could be used. jo.offsetParent() is the first non-static common parent (i.e. the absolute-positioning base) jo.position() relative to the .offsetParent() of FIRST matching El This is precisely what .left/.top mean with abs. positioning. jqueryui provides a jo.position(...) (for setting not just reading position). jo.offset(topLeftCoordsObj) Place El(s) relatively jo.trigger(eventType, params) or jo.trigger(jqEvent). Like DOM .click(), but triggers any specified event, not just click. jo.triggerHandler() does less thatn jo.trigger(...). jo.val() Sets/gets .value of FIRST matching element. For multisels returns array. !IMPORTANT: For radios and checkboxes will want to narrow to checkeds (with *:checked). const isChecked = !!$("selector:checked").val(); wrapeeJo.wrap[Inner](wrappingEl) wraps EACH. wrappingEl has only 1 inner-most el.. If "Inner" then wraps only contents. wrapeeJo.wrap[Inner](fn) wraps EACH. 'this' in executing function is wrapee DOM El. "Inner" wraps only the conts. wrapeeJo.wrapAll(wrappingEl) does one wrapping jo.unwrap() removes parent, transplanting jo and their peers 1 level up. JQUERY SELECTORS generate a JQuery object instance, which aggregates an iterable list of 0 or more DOM Elements. Just like PrototypeJS, selectors normally match only XML or DOM Elements, not text or comment nodes. There are exceptions though, like jo.content(). (N.b. selectors are not just strings, but some "selection" of existing DOM element(s), for example, can convert a single or array of DOM element(s)). ! Optional 2nd param, like: $("selector", context) changes the scope of selection from the entire DOM doc. (Could accomplish same by using the jo.find(...) method). So they work well with the selectors like jo.jQueryFn(...), JQuery-supplied methods usually do each internally. If you want to use a non-JQuery method on the set from a selector, you must invoke .each manually. $("*") selects all elements in the doc. $(domElement) $("#id") XPath-like [] operator for tag attribute matching: [x]: Has attr name "x". [x="v"]: Has attr name "x" and value y [x!="v"]: Figger it out. [many others] ????? Same tutorial also has $("#parentelid tag.class") ??? Difference between $("x y") vs. $("x").find("y") not explained. x + y Matches y if it immediately follows peer matching x. x ~ y Matches y's that follow peer matching x. : selector-operators. Immensely useful. Critical ones here: :animated animating right now :button gets both