Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery HTML / CSS Methods

jQuery HTML / CSS Methods


jQuery HTML / CSS Methods

The following table lists all jQuery methods for handling HTML and CSS.

The following methods apply to both HTML and XML documents, except for the html() method.

Method Description
addClass() Add one or more class names to the selected elements
after() Insert content after the selected elements
append() Insert content at the end of the selected elements
appendTo() Insert HTML elements at the end of the selected elements
attr() Set or return the attribute/value of the selected elements
before() Insert content before the selected elements
clone() Generate a copy of the selected elements
css() Set or return one or more style properties for the selected elements
detach() Remove the selected elements (retaining data and events)
empty() Remove all child nodes and content from the selected elements
hasClass() Check whether the selected elements contain the specified class name
height() Set or return the height of the selected elements
html() Set or return the content of the selected elements
innerHeight() Return the height of an element (including padding, excluding border)
innerWidth() Return the width of an element (including padding, excluding border)
insertAfter() Insert HTML elements after the selected elements
insertBefore() Insert HTML elements before the selected elements
offset() Set or return the offset coordinates of the selected elements (relative to the document)
offsetParent() Return the first positioned ancestor element
outerHeight() Return the height of an element (including padding and border)
outerWidth() Return the width of an element (including padding and border)
position() Return the position of an element (relative to the parent element)
prepend() Insert content at the beginning of the selected elements
prependTo() Insert HTML elements at the beginning of the selected elements
prop() Set or return the attribute/value of the selected elements
remove() Remove the selected elements (including data and events)
removeAttr() Remove one or more attributes from the selected elements
removeClass() Remove one or more classes from the selected elements
removeProp() Remove attributes set via the prop() method
replaceAll() Replace the selected elements with new HTML elements
replaceWith() Replace the selected elements with new content
scrollLeft() Set or return the horizontal scrollbar position of the selected elements
scrollTop() Set or return the vertical scrollbar position of the selected elements
text() Set or return the text content of the selected elements
toggleClass() Toggle between adding/removing one or more classes on the selected elements
unwrap() Remove the parent element of the selected elements
val() Set or return the property value of the selected elements (for form elements)
width() Set or return the width of the selected elements
wrap() Wrap each selected element with an HTML element
wrapAll() Wrap all selected elements with an HTML element
wrapInner() Wrap the content of each selected element with an HTML element
$.escapeSelector() Escape characters or strings that have special meaning in CSS selectors
$.cssHooks Provides a way to get and set specific CSS values by defining functions