Copy codeThe Code is as follows:
<Html>
<Head>
<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 Methods for adding nodes
// $ ("P"). append ("<B> how are you? </B> "); // append B to the p element.
// $ ("<B> how are you? </B> "). appendTo (" p "); // append B to the p element.
// $ ("P"). prepend ("<B> how are you? </B> "); // forward B to p
// $ ("<B> how are you? </B> "). prependTo (" p "); // forward B to the p element.
// $ ("P"). after ("<B> how are you? </B> "); // insert B to the p element
// $ ("<B> how are you? </B> "). insertAfter (" p "); // insert B to the end of p.
// $ ("P"). before ("<B> how are you? </B> "); // Add B before p.
// $ ("<B> how are you? </B> "). insertBefore (" p "); // insert B to the front of the p element.
// Several Methods to delete a node
// Var $ li = $ ("ul li: eq (1)"). remove (); // Delete the 2nd element nodes in the ul Node
// $ ("Ul"). append ($ li); // Add the deleted element node to the ul Element
// $ ("Ul li"). remove ("li [title! = Pineapple] "); // Delete the li element with the title attribute not equal to" pineapple "under the ul Element
// $ ("Ul li: eq (1)"). empty (); // clear the content of the 2nd li elements under the ul Node
// Copy a node
/* $ ("Ul li"). click (function (){
$ (This ). clone (true ). appendTo ("ul"); // copy the currently clicked node and append it to the ul element. When a parameter is added, copy its event.
});
*/
// Replace the node
// $ ("P"). replaceWith ("<strong> what is your favorite fruit? </Strong> ");
});
</Script>
</Head>
<Body>
<P> hello! </P>
What is your favorite fruit?
<Ul>
<Li title = "apple"> Apple </li>
<Li title = "orange"> orange </li>
<Li title = "pineapple"> pineapple </li>
</Ul>
</Body>
</Html>