CARVIEW |
Manipulation
All of the methods in this chapter manipulate the DOM in some manner. A few of them simply change one of the attributes of an element (also listed in the Attributes category), while others set an element’s style properties (also listed in the CSS category). Still others modify entire elements (or groups of elements) themselves—inserting, copying, removing, and so on. All of these methods are referred to as “setters,” as they change the values of properties.
A few of these methods—such as .attr()
, .html()
, and .val()
—also act as “getters,” retrieving information from DOM elements for later use.
-
.addClass()
Attributes, Class Attribute, CSSAdds the specified class(es) to each of the set of matched elements.
-
.after()
DOM Insertion, OutsideInsert content, specified by the parameter, after each element in the set of matched elements.
-
.append()
DOM Insertion, InsideInsert content, specified by the parameter, to the end of each element in the set of matched elements.
-
.appendTo()
DOM Insertion, InsideInsert every element in the set of matched elements to the end of the target.
-
.attr()
Attributes, General AttributesGet the value of an attribute for the first element in the set of matched elements.
-
.before()
DOM Insertion, OutsideInsert content, specified by the parameter, before each element in the set of matched elements.
-
.clone()
CopyingCreate a deep copy of the set of matched elements.
-
.css()
CSS, Style PropertiesGet the value of a style property for the first element in the set of matched elements.
-
.detach()
DOM RemovalRemove the set of matched elements from the DOM.
-
.empty()
DOM RemovalRemove all child nodes of the set of matched elements from the DOM.
-
.hasClass()
Attributes, Class Attribute, CSSDetermine whether any of the matched elements are assigned the given class.
-
.height()
CSS, Dimensions, Style PropertiesGet the current computed height for the first element in the set of matched elements.
-
.html()
Attributes, DOM Insertion, InsideGet the HTML contents of the first element in the set of matched elements.
-
.innerHeight()
CSS, Dimensions, Style PropertiesGet the current computed height for the first element in the set of matched elements, including padding but not border.
-
.innerWidth()
CSS, Dimensions, Style PropertiesGet the current computed width for the first element in the set of matched elements, including padding but not border.
-
.insertAfter()
DOM Insertion, OutsideInsert every element in the set of matched elements after the target.
-
.insertBefore()
DOM Insertion, OutsideInsert every element in the set of matched elements before the target.
-
.offset()
CSS, Offset, Style PropertiesGet the current coordinates of the first element in the set of matched elements, relative to the document.
-
.outerHeight()
CSS, Dimensions, Style PropertiesGet the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements.
-
.outerWidth()
CSS, Dimensions, Style PropertiesGet the current computed width for the first element in the set of matched elements, including padding and border.
-
.position()
CSS, Offset, Style PropertiesGet the current coordinates of the first element in the set of matched elements, relative to the offset parent.
-
.prepend()
DOM Insertion, InsideInsert content, specified by the parameter, to the beginning of each element in the set of matched elements.
-
.prependTo()
DOM Insertion, InsideInsert every element in the set of matched elements to the beginning of the target.
-
.prop()
Attributes, General AttributesGet the value of a property for the first element in the set of matched elements.
-
.remove()
DOM RemovalRemove the set of matched elements from the DOM.
-
.removeAttr()
Attributes, General AttributesRemove an attribute from each element in the set of matched elements.
-
.removeClass()
Attributes, Class Attribute, CSSRemove a single class, multiple classes, or all classes from each element in the set of matched elements.
-
.removeProp()
Attributes, General AttributesRemove a property for the set of matched elements.
-
.replaceAll()
DOM ReplacementReplace each target element with the set of matched elements.
-
.replaceWith()
DOM ReplacementReplace each element in the set of matched elements with the provided new content.
-
.scrollLeft()
CSS, Offset, Style PropertiesGet the current horizontal position of the scroll bar for the first element in the set of matched elements.
-
.scrollTop()
CSS, Offset, Style PropertiesGet the current vertical position of the scroll bar for the first element in the set of matched elements.
-
.text()
DOM Insertion, InsideGet the combined text contents of each element in the set of matched elements, including their descendants.
-
.toggleClass()
Attributes, Class Attribute, CSSAdd or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
-
.unwrap()
DOM Insertion, Around, DOM RemovalRemove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
-
.val()
Attributes, Forms, General AttributesGet the current value of the first element in the set of matched elements.
-
.width()
CSS, Dimensions, Style PropertiesGet the current computed width for the first element in the set of matched elements.
-
.wrap()
DOM Insertion, AroundWrap an HTML structure around each element in the set of matched elements.
-
.wrapAll()
DOM Insertion, AroundWrap an HTML structure around all elements in the set of matched elements.
-
.wrapInner()
DOM Insertion, AroundWrap an HTML structure around the content of each element in the set of matched elements.
jQuery API
-
Keyboard navigation now available! Use up, down, tab, shift+tab, shift+upArrow and enter to navigate.
Browse the jQuery API
© 2012 The jQuery Foundation
Sponsored by Media Temple and others.