DOM manipulation methods
DOM manipulation methods are discussed in detail in Chapter 5.
Attributes and properties
Manipulation Method |
Description |
---|---|
|
Get the attribute named |
|
Set the attribute named |
|
Set the attribute named |
|
Set attribute values, given as key-value pairs |
|
Remove the attribute named |
|
Get the property named |
|
Set the property named |
|
Set the property named |
|
Set property values, given as key-value pairs. |
|
Remove the property named |
|
Add the given class to each matched element. |
|
Remove the given class from each matched element |
|
Remove the given class if present, and add it if not, for each matched element |
|
Return |
|
Get the value attribute of the first matched element |
|
Set the value attribute of each element to |
Content
Manipulation Method |
Description |
---|---|
|
Get the HTML content of the first matched element |
|
Set the HTML content of each matched element to value |
|
Get the textual content of all matched elements as a single string |
|
Set the textual content of each matched element to |
CSS
Manipulation Method |
Description |
---|---|
|
Get the CSS attribute named |
|
Set the CSS attribute named |
|
Set CSS attribute values, given as key-value pairs |
Dimensions
Manipulation Method |
Description |
---|---|
|
Get the top, and left, pixel coordinates of the first matched element, relative to the viewport |
|
Get the top, and left, pixel coordinates of the first matched element, relative to the element returned by |
|
Get the vertical scroll position of the first matched element |
|
Set the vertical scroll position of all matched elements to |
|
Get the horizontal scroll position of the first matched element |
|
Set the horizontal scroll position of all matched elements to |
|
Get the height of the first matched element |
|
Set the height of all matched elements to |
|
Get the width of the first matched element |
|
Set the width of all matched elements to |
|
Get the height of the first matched element, including padding, but not border |
|
Get the width of the first matched element, including padding, but not border |
|
Get the height of the first matched element, including padding, border, and optional margin |
|
Get the width of the first matched element, including padding, border, and optional margin |
Insertion
Manipulation Method |
Description |
---|---|
|
Insert |
|
Insert the matched elements at the end of the interior of the elements matched by |
|
Insert |
|
Insert the matched elements at the beginning of the interior of the elements matched by |
|
Insert |
|
Insert the matched elements after each of the elements matched by |
|
Insert |
|
Insert the matched elements before each of the elements matched by |
|
Wrap each of the matched elements within |
|
Wrap all of the matched elements as a single unit within |
|
Wrap the interior contents of each of the matched elements within |
Replacement
Manipulation Method |
Description |
---|---|
|
Replace the matched elements with |
|
Replace the elements matched by |
Removal
Manipulation Method |
Description |
---|---|
|
Remove the child nodes of each matched element |
|
Remove the matched nodes (optionally filtered by |
|
Remove the matched nodes (optionally filtered by |
|
Remove the element's parent |
Copying
Manipulation Method |
Description |
---|---|
|
Make a copy of all matched elements, optionally also copying event handlers |
Data
Manipulation Method |
Description |
---|---|
|
Get the data item named |
|
Set the data item named |
|
Remove the data item named |