1. Finding nodes
Use the jquery selector to complete
1.1 Finding ELEMENT nodes
$ ("ul Li:eq (1)")
1.2 Finding attribute Nodes
var $para = $ ("P");
var p_txt = $para. attr ("title");
2. Create a Node
2.1 Creating an Element node
var $li _1 = $ ("<li></li>");
$ ("ul"). Append ($li _1);
2.2 Creating a text node
var $li _1 = $ ("<li> banana </li>");
$ ("ul"). Append ($li _1);
2.3 Creating an Attribute node
var $li _1 = $ ("<li title= ' banana ' > Banana </li>");
$ ("ul"). Append ($li _1);
3. Inserting nodes
Methods for inserting nodes
Append (): Append content to each matching element
AppendTo (): Appends all matching elements to the specified element
Prepend (): front content to each matched element
Prependto (): Place all matching elements in front of the specified element
After (): Insert content after each element
InsertAfter (): After () opposite
Before (): Insert content before each matching element
InsertBefore (): Before () instead
4. Delete a node
4.1 Remove method
$ ("ul Li:eq (1)"). Remove ();
$ ("ul Li"). Remove ("li[title!= pineapple");
4.2 Empty method
$ ("ul Li:eq (1))"). empty ();
5. Copying nodes
$ ("ul Li"). Click (function () {
$ (this). Clone (). AppendTo ("ul");
})
$ (this). Clone (True). AppendTo ("body"); Adds true to make the copied new element have the original behavior
¥ (This). AppendTo ("body"); Mobile Node
6. Replacing nodes
$ ("P"). ReplaceWith ("<strong>text</strong>");
$ ("<strong>text</strong"). ReplaceAll ("P");
7. Parcel Nodes
$ ("strong"). Wrap ("<b></b>"); Separate packages for all elements
$ ("strong"). Wrapall ("<b></b>"); Wrap all matching elements with one element
$ ("strong"). Wrapinner ("<b></b>"); Wraps the child content of each matching element (including the text node) with other structured tags.
Dom operations in jquery