Вы находитесь на странице: 1из 9

jQuery DOM Manipulation Methods:

1. General attributes
.attr() (getter) .attr() (setter) .removeAttr()

4. DOM replacement
.html() (getter) .html() (setter) .text() (getter) .text() (setter) .val() (getter) .val() (setter) .replaceWith() .replaceAll()

2. Style properties
.css() (getter) .css() (setter) .height() (getter) .height() (setter) .innerHeight() .outerHeight() .width() (getter) .width() (setter) .innerWidth() .outerWidth() .offset() (getter) .offset() (setter) .position() .scrollTop() (getter) .scrollTop() (setter) .scrollLeft() (getter) .scrollLeft() (setter)

5. DOM insertion, inside


.prepend() .prependTo() .append() .appendTo()

6. DOM insertion, outside


.before() .insertBefore() .after() .insertAfter()

7. DOM insertion, around


.wrap() .wrapAll() .wrapInner()

3. Class attributes
.hasClass() .addClass() .removeClass() .toggleClass()

8. DOM copying
.clone()

9. DOM removal
.empty() .remove() .detach() .unwrap()

jQuery Traversal Methods:


1. Filtering methods
.filter() .not() .has() .eq() .first() .last() .slice()

2. Tree traversal methods


.find() .children() .parents() .parentsUntil() .parent() .closest() .offsetParent() .siblings() .prev() .prevAll() .prevUntil() .next() .nextAll() .nextUntil()

3. Miscellaneous traversal methods


.add() .is() .end() .andSelf() .map() .contents()

jQuery Event Methods:


1. Event handler attachment
.bind() .unbind() .one() .trigger() .triggerHandler()

2. Document loading
.ready() .load() .unload() .error()

3. Mouse events
.mousedown() .mouseup() .click() .dblclick() .toggle() .mouseover() .mouseout() .mouseenter() .mouseleave() .hover() .mousemove()

4. Form events
.focus() .blur() .change() .select() .submit()

5. Keyboard events
.keydown() .keypress() .keyup() Browser events: .resize(),.scroll()

jQuery Effect Methods


1. Pre-packaged effects
.show() .hide() .toggle() .slideDown() .slideUp() .slideToggle() .fadeIn() .fadeOut() .fadeTo()

2. Customized effects
.animate() .stop() .delay() .queue() .dequeue() .clearQueue()

jQuery AJAX Methods:


1. Low-level interface
$.ajax() $.ajaxSetup()

2. Shorthand methods
$.get() .load() $.post() $.getJSON() $.getScript()

3. Global AJAX event handlers


.ajaxComplete() .ajaxError() .ajaxSend() .ajaxStart() .ajaxStop() .ajaxSuccess()

4. Helper functions
.serialize() .serializeArray()

jQuery Miscellaneous Methods:


1. Setup methods
$.noConflict()

2. DOM element methods


.size() .get() .index()

3. Collection manipulation
.each() $.grep() $.makeArray() $.inArray() $.map() $.merge() $.unique() $.extend() $.trim() $.param()

4. Introspection
$.isArray() $.isFunction() $.isPlainObject() $.isEmptyObject() $.isXMLDoc()

5. Data storage
.data() .removeData()

jQuery Selectors:
Selector Example
List accurate as of jQuery 1.3

Description

* #id .class

$(*); $(#id); $(.class)

This selector is a wild card method and will select all elements in a document. This selector selects an element with the given ID. The class selector will gather all elements in the document with the given class name This selector will collect all elements in a document with the given tag name i.e. table, ul, li, a etc. This method can use multiple selection patterns to collect elements. This will select all a elements that are a descendant of li This will select all b elements which are a child element of a or in our example all tr elements in a table or tables. This will select all a elements that are an immediate descendant of li in our example. This selector will select all ul elements that are a sibling of p Returns the first element in a result set Returns the first child element of the parent element. Returns the last element in a result set Returns the last child element of the parent element. Returns elements which are the only child of the parent element. Returns all elements that are not a on in our example all input elements that are not checked Returns all elements with a descendant that matches a in out example a div that contains a p. Returns all odd elements in a result set (zero based)

element

$(element)

a, b, c. n parent child a>b

$(th, td, .class, #id) $(li a) $(table > tr);

a+b

$(li + a);

a~b :first :first-child :last :last-child nly-child :not(a)

$(p ~ ul); $(ul li:first); $(ul li:first-child); $(ul li:last); $(ul li:last-child); $(div p:only-child); $(input:not(:checked));

:has(a)

$(div:has(p));

dd

$(ul li:odd);

Selector :even :eq(n) :gt(n) :lt(n) :nth-child(n) :nth-child(odd) :nth-child(even) :nth-child(formula)

Example $(ul li:even); $(ul li:eq(n)); $(ul li:gt(n)); $(ul li:lt(n)); $(ul li:nth-child(n)); $(ul li:nth-child(odd)); $(ul li:nth-child(even)); $(ul li:nth-child(3n));

Description Returns all even elements in a result set (zero based) Returns a numbered element identified by n (zero based) Returns all elements in a result set greater than n (zero based) Returns all elements in a result set less than n (zero based) Returns the nth child in a result set (one based) Returns all odd numbered elements in a result set (one based) Returns all even numbered elements in a result set (one based) Returns every nth child in a result set. In our example every third child (one based) Returns all heading elements e.g. h1, h2, etc. Returns elements with an animation currently in progress Returns all elements containing the passed string Returns all elements that contain no child nodes Returns all elements that a parent nodes to any other DOM element including text nodes. Returns all hidden elements that are hidden with CSS or input fields of the type hidden Returns all visible elements Returns all elements that contain the passed attribute in our example any element with a href attribute Returns all elements that the passed attribute value is equal to the passed value. In our example ant element with a rel attribute equal to external Returns all elements that the passed attribute value is not equal to the passed value. In our example ant element with a

:header :animated :contains(text) :empty :parent

$(:header); $(ul:animated); $(:contains(hello)); $(:empty); $(li:parent);

:hidden

$(ul:hidden);

:visible [attribute]

$(ul:visible); $([href]);

[attribute=value]

$([rel=external]);

['attribute!=value']

$([rel!=external]);

Selector

Example

Description rel attribute that is not equal to external

[attribute!=value]

$([class^=open]);

Returns all elements that the passed attribute value start with the passed value. In our example any element thats class attribute value begins with open Returns all elements that the passed attribute value ends with the passed value. In our example any element whos id ends with -wrapper Returns all elements that the passed attribute value contains the passed value. In our example any element whos class contains the string offer Returns only input elements of the tag name input, select, textarea and button Returns only input elements of the type text Returns only input elements of the type password Returns only input elements of the type radio Returns only input elements of the type checkbox Returns only input elements of the type submit Returns only input elements of the type image Returns only input elements of the type reset Returns only input elements of the type file Returns only input elements of the type button Returns all enabled input elements Returns the selected element in a select list. Returns disabled input elements Returns checked input elements of the type radio or checkbox.

[attribute$=value]

$([id$=-wrapper]);

[attribute*=value]

$([class*=offer]);

:input :text :password :radio :checkbox :submit :image :reset :file :button :enabled :selected :disabled :checked

$(:input); $(:text); $(:password); $(:radio); $(:checkbox); $(:submit); $(:image); $(:reset); $(:file); $(:button); $(:enabled); $(:selected); $(:disabled); $(:checked);

Вам также может понравиться