Copy Code code as follows:
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title>jquery Insert, copy, replace, and delete nodes </title>
<script type= "Text/javascript" src= "Jquery-1.3.2.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
Several ways to add nodes
$ ("P"). Append ("<b> How are You?") </b> ");//append" B "to P element
$ ("<b> How are You?") </b> "). Appendto (" P ");//append" B "to P element
$ ("P"). Prepend ("<b> How are You?") </b> ");//forward" B "to P
$ ("<b> How are You?") </b> "). Prependto (" P ");//put" B "before the P element
$ ("P"). After ("<b> How are you?" </b> ");//insert" B "after P-element
$ ("<b> How are You?") </b> "). InsertAfter (" P ");//insert" B "behind P element
$ ("P"). Before ("<b> How are You?") </b>);//Add "B" before P element
$ ("<b> How are You?") </b> "). InsertBefore (" P ");//insert" B "in front of P element
Several ways to delete a node
var $li =$ ("ul li:eq (1)"). Remove ()//delete the 2nd element node in the UL node
$ ("ul"). Append ($li);//Add newly deleted element node to UL element
$ ("ul Li"). Remove ("li[title!= pineapple]")//delete the LI element under the title attribute not equal to "pineapple" under the UL element
$ ("ul Li:eq (1)"). Empty ()//clear the contents of the 2nd Li element under the UL node
Replication node
/* $ ("ul Li"). Click (function () {
$ (this). Clone (True). Appendto ("ul");//Copy the currently clicked node and append it to the "ul" element, copying its event when adding parameters
});
*/
Replacing nodes
$ ("P"). ReplaceWith ("<strong> What is your least favorite fruit?" </Strong> ");
});
</script>
<body>
<p> Hello! </p>
What's your favorite fruit?
<ul>
<li title= "Apple" > Apple </li>
<li title= "Orange" > Orange </li>
<li title= "Pineapple" > Pineapple </li>
</ul>
</body>