JQuery Document Processing
1. Internal insertion
1.1 append (content | fn) append content to each Matching Element
$ ("P"). append ("appent ")
$ ("P"). append (function (index, html ){
Return index + "index value in this set" + html + "original html value of this object"
})
1.2 appendTo (content) append all matched elements to another specified element set. By using this method, the general $ (A). append (B) operation is reversed, that is, not to append B to A, but to append A to B.
$ ("P"). appendTo ("p ");
$ ("
Pppppppp
"). AppendTo (" p "). addClass (" active ");
2.3 PRepend (content | fn) pre-content to each Matching Element
$ ("P"). prepend ("prepend ");
$ ("P"). prepend (function (index, html) {return index + html })
2.4 prependTo (content) puts all matched elements in front of another and specified element set.
$ ("P"). prependTo ("p ");
2. External insertion
2.1 after (content | fn) insert content after each Matching Element
$ ("P"). after ("after ");
$ ("P"). after (function (I, html) {return I + html });
2.2 before (content | fn) insert content before each Matching Element
$ ("P"). after ($ ("# id") [0]);
$ ("P"). after ($ ("span "));
2.3 insertAfter (content) inserts all matching elements to the end of another specified Element Set.
$ ("InsertAfter"). insertAfter ("p ");
2.4 insertBefore (content) inserts all matching elements in front of another specified Element Set.
$ ("InsertBefore"). insertBefore ("p ");
3. Packages
3.1 wrap (html | element | fn) wraps all matching elements with structured tags of other elements.
$ ("P"). wrap ("
");
$ ("P"). wrap (document. getElementById ('content '));
$ (". Wrap"). wrap (function (){
Return'
';
})
3.2 The unwrap () method removes the parent element of the element.
$ ("P"). unwrap ();
3.3 wrapAll (html | elem) wraps all matching elements with a single element
$ ("P"). wrapAll ("p ");
3.4 wrapInner (html | element | fn) wraps the child content (including text nodes) of each matching element in an HTML structure.
$ ("P"). wrapInner ("
");
$ ("P"). wrapInner (document. createElement ('B '))
$ (". Inner"). wrapInner (function (){
Return'
';
})
4. Replace
4.1 replaceWith (content | fn) replaces all matching elements with the specified HTML or DOM element.
$ ("P"). replaceWith ("
ReplaceWith");
$ ("P"). replaceWith (function (){
Return'
$ (This). text ()
';
});
4.2 replaceAll (selector) replaces all elements matched by selector with matched elements.
$ ("
ReplaceAll"). ReplaceAll (" p ");
5. Delete
5.1 empty () deletes all child nodes in the matched element set.
$ ("P"). empty ()
5.2 remove ([expr]) removes all matching elements from the DOM. This method does not delete the matching elements from the jQuery object. Therefore, these matching elements can be used in the future. However, in addition to retaining this element, other events such as bound events and additional data will be removed.
$ ("P"). remove ();
$ ("P"). remove (". remove ");
5.3 detach ([expr]) removes all matching elements from the DOM. This method does not delete the matching elements from the jQuery object, so these matching elements can be used in the future. Unlike remove (), all bound events and additional data are retained.
$ ("P"). detach ();
$ ("P"). detach (". detach ");
6. Copy
6.1 clone ([even [, deepEven]) clone the matched DOM elements and select these cloned copies.
A boolean value (true or false) of Even indicates whether the event processing function will be copied.
$ ("B "). clone (). prependTo ("p"); // clone all B elements (and select copies of these clones) and forward them to all sections.
$ ("Button"). click (function () {// create a button, which can copy itself and has the same function.
$ (This). clone (true). insertAfter (this );
});
The above is the content processed by the jQuery document. For more related articles, please follow the PHP Chinese Network (www.php1.cn )!