Panduan Rujukan jQuery - Operasi Dokumen

jQuery document manipulation methods

These methods are applicable to both XML documents and HTML documents, except: html().

Method Description
addClass() Add specified class names to the matched elements.
after() Insert content after the matched elements.
append() Insert the specified content at the end of each element in the matched element collection.
appendTo() Insert each element of the matched element collection at the end of the target.
attr() Set or return the attributes and values of the matched elements.
before() Insert content before each matched element.
clone() Create a copy of the matched element collection.
detach() Remove the matched element collection from the DOM.
empty() Remove all child nodes from the matched element collection.
hasClass() Check if the matched elements have the specified class.
html() Set or return the HTML content of the matched element collection.
insertAfter() Insert the matched elements after another specified element collection.
insertBefore() Insert the matched elements before another specified element collection.
prepend() Insert the specified content at the beginning of each element in the matched element collection.
prependTo() Insert each element of the matched element collection at the beginning of the target.
remove() Remove all matched elements.
removeAttr() Remove specified attributes from all matched elements.
removeClass() Remove all or specified classes from all matched elements.
replaceAll() Replace all matched elements with the matching elements.
replaceWith() Replace the matched elements with new content.
text() Set or return the content of the matched elements.
toggleClass() 从匹配的元素中添加或删除一个类。
unwrap() 移除并替换指定元素的父元素。
val() 设置或返回匹配元素的值。
wrap() 把匹配的元素用指定的内容或元素包裹起来。
wrapAll() 把所有匹配的元素用指定的内容或元素包裹起来。
wrapinner() 将每一个匹配的元素的子内容用指定的内容或元素包裹起来。