1. Create a Node
var AA = $ ("<div id= ' CCCC ' > Insert Content </div>") var bb = $ ("<a href= ' http://www.baidu.com ' > Baidu a bit </a > ")//Create node//Insert node// Internal Insert//insert into the inner front// $ (" div "). Append (BB)// append: Inserted into the back of the node inside// $ (" h6 "). AppendTo ("div")// AppendTo: Move the H6 tag to the back of the DIV tag, the original H6 tag will no longer exist// insert inside the back// $ ("div"). Prepend (BB)// prepend: Inserted into the front of the node inside the// $ ("div"). Prependto (BB)// prependto: Move h6 this tag to the front of the DIV tag, the original H6 tag will no longer exist// an external insert, which is equivalent to a sibling insert, including the back of the sibling and the front// $ ("div"). After (AA)//after : Inserts a AA label in the lower position of the div's sibling tag,// $ ("div" ). Before (AA)// before: Inserts a AA label in the upper position of the Div's sibling label,// $ ("h6"). InsertBefore ("div")// InsertBefore: Moves the specified label to the front of the DIV tag, and the original label disappears// $ ("H1"). InsertAfter ("div")// InsertAfter: Moves the specified label to the back of the DIV tag, the original label no longer exists
2, Operation node, including package, delete, replace, copy
$ (function () {//$ ("div"). Wrap ("<strong> contents of package Tag </strong>")//wrap div tag with strong tag//$ (f Unction () {//$ ("div"). Wrap ("<strong><em></em></strong>")//})//with <strong> <em></em></strong> double label Wrapping DIV tag, here is support multi-layer label Package//$ ("em"). Unwrap ()//Remove the label of the first layer package outside the EM label//WR AP and Wrapall comparison: As explained in the following example, if there is only one div, then there is no difference between the two, if there are multiple div, then the former will be each div as a separate tag, and then use the strong//tag to wrap multiple div tags, the latter will put two di V is one, which means to wrap two div//$ ("div") with a strong. Wrapall ("<strong> contents of the package Tag </strong>")//$ ("em"). Wra PInner ("<div></div>")//wrapinner: The meaning of wrapping a layer of labels inside, similarly, this also supports multi-layer label packages//Clone nodes//$ ("div"). Click (Fu Nction () {//alert ("123")//})/$ ("body"). Append ($ ("div"). Clone ())//Clone One node, and then append the node to the inside of the body tag, if there is no parameter, or if the parameter is False, if the original label has Shijian, the//$ ("body") is not copied. Append ($ ("div"). Clone (True))// Clone a node, and then put the nodeAppend to the inside of the body tag, if the parameter is true, if the original label has Shijian, then the node will be copied//deleted, the remove can have parameters, parameters can do more filtering restrictions, such as ID class, if it is empty, it will be all deleted Remove//$ ("em"). Remove ("#bbb")//Replace node $ ("#ccc"). ReplaceWith ("
Node operations for jquery