$(this).hide() - hides the current element.
$("p").hide() - hides all <p> elements.
$("p.test").hide() - hides all <p> elements with class="test".
$("#test").hide() - hides the element with id="test".
jQuery Effect Methods
The following table lists all the methods used to create animation effects.
Method | Description |
---|---|
animate() | Runs a custom animation (of a set of CSS properties) on selected elements |
clearQueue() | Removes all queued functions on selected elements |
delay() | Sets a delay for all queued functions on selected elements |
dequeue() | Runs the next queued functions on selected elements |
fadeIn() | Fades in selected elements |
fadeOut() | Fades out selected elements |
fadeTo() | Fades in/out selected elements to a given opacity |
fadeToggle() | |
hide() | Hides selected elements |
queue() | Shows the queued functions on selected elements |
show() | Shows selected elements |
slideDown() | Slide-down (show) selected elements |
slideToggle() | Toggles slideUp() and slideDown() on selected elements |
slideUp() | Slide-up (hide) selected elements |
stop() | Stops a running animation on selected elements |
toggle() | Toggles between hide() and show(), or custom functions, on selected elements |
jQuery HTML Methods 点击相应的方法会有对应的例子
The following table lists all the methods used to manipulate the DOM.
The methods below work for both HTML and XML documents. Exception: the html() method.
Method | Description |
---|---|
addClass() | Adds one or more classes (for CSS) to selected elements |
after() | Inserts content after selected elements //重要 |
append() | Inserts content at the end of (but still inside) selected elements//重要 |
appendTo() | Inserts content at the end of (but still inside) selected elements |
attr() | Sets or returns an attribute and value of selected elements |
before() | Inserts content before selected elements //重要 |
clone() | Makes a copy of selected elements |
detach() | Removes (but keeps a copy of) selected elements |
empty() | Removes all child elements and content from selected elements |
hasClass() | Checks if any of the selected elements have a specified class (for CSS) |
html() | Sets or returns the content of selected elements //重要 |
insertAfter() | Inserts HTML markup or elements after selected elements |
insertBefore() | Inserts HTML markup or elements before selected elements |
prepend() | Inserts content at the beginning of (but still inside) selected elements //重要 |
prependTo() | Inserts content at the beginning of (but still inside) selected elements |
remove() | Removes selected elements |
removeAttr() | Removes an attribute from selected elements |
removeClass() | Removes one or more classes (for CSS) from selected elements |
replaceAll() | Replaces selected elements with new content |
replaceWith() | Replaces selected elements with new content |
text() | Sets or returns the text content of selected elements |
toggleClass() | Toggles between adding/removing one or more classes (for CSS) from selected elements |
unwrap() | Removes the parent element of the selected elements |
val() | Sets or returns the value attribute of the selected elements (form elements) |
wrap() | Wraps specified HTML element(s) around each selected element |
wrapAll() | Wraps specified HTML element(s) around all selected elements |
wrapInner() | Wraps specified HTML element(s) around the content of each selected element |