jQuery HTML / CSS
Methods
jQuery HTML / CSS Methods
The table below lists all the jQuery methods used for handling HTML and CSS.
The following methods work for both HTML and XML documents. Except for the html()
method.
Method | Description |
---|---|
addClass() | Adds one or more class names to the selected elements |
after() | Inserts content after the selected elements |
append() | Inserts content at the end of the selected elements |
appendTo() | Inserts HTML elements at the end of the selected elements |
attr() | Sets or returns the attributes/values of the selected elements |
before() | Inserts content before the selected elements |
clone() | Creates a copy of the selected elements |
css() | Sets or returns one or more style properties for the selected elements |
detach() | Removes the selected elements (keeps data and events) |
empty() | Removes all child nodes and content from the selected elements |
hasClass() | Checks if the selected elements contain the specified class name |
height() | Sets or returns the height of the selected elements |
html() | Sets or returns the content of the selected elements |
innerHeight() | Returns the height of the element (includes padding, excludes border) |
innerWidth() | Returns the width of the element (includes padding, excludes border) |
insertAfter() | Inserts HTML elements after the selected elements |
insertBefore() | Inserts HTML elements before the selected elements |
offset() | Sets or returns the offset coordinates of the selected elements (relative to the document) |
offsetParent() | Returns the first positioned ancestor element |
outerHeight() | Returns the height of the element (includes padding and border) |
outerWidth() | Returns the width of the element (includes padding and border) |
position() | Returns the position of the element (relative to the parent) |
prepend() | Inserts content at the beginning of the selected elements |
prependTo() | Inserts HTML elements at the beginning of the selected elements |
prop() | Sets or returns the attributes/values of the selected elements |
remove() | Removes the selected elements (including data and events) |
removeAttr() | Removes one or more attributes from the selected elements |
removeClass() | Removes one or more classes from the selected elements |
removeProp() | Removes properties set by the prop() method |
replaceAll() | Replaces the selected elements with new HTML elements |
replaceWith() | Replaces the selected elements with new content |
scrollLeft() | Sets or returns the horizontal scrollbar position of the selected elements |
scrollTop() | Sets or returns the vertical scrollbar position of the selected elements |
text() | Sets or returns the text content of the selected elements |
toggleClass() | Toggles between adding/removing one or more classes from the selected elements |
unwrap() | Removes the parent element of the selected elements |
val() | Sets or returns the attribute values of the selected elements (for form elements) |
width() | Sets or returns the width of the selected elements |
wrap() | Wraps HTML elements around each selected element |
wrapAll() | Wraps HTML elements around all selected elements |
wrapInner() | Wraps HTML elements around the content of each selected element |
$.escapeSelector() | Escapes special characters or strings in CSS selectors |
$.cssHooks | Provides a way to get and set specific CSS values by defining functions |