Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> jquery </title>
<Script type = "text/javascript" src = "jquery-1.7.2.js"> </script>
<Script type = "text/javascript">
$ (Function (){
// Append () Usage
// $ ("Ul"). append ("<li title = 'abc'> hello </li> ");
// $ ("Ul"). append ("<li title = 'xyz'> world </li> ");
// AppendTo () Usage
$ ("<Li title = 'xyz'> hello </li>"). appendTo ($ ("ul "));
});
</Script>
</Head>
<Body>
<P title = "hello world"> do you think the Shengsi garden training is good? </P>
<Ul>
<Li title = "1"> good </li>
<Li title = "2"> good </li>
<Li title = "3"> excellent </li>
<Li title = "4"> excellent </li>
<Li title = "5"> great </li>
<Li title = "6"> I cannot describe it </li>
</Ul>
</Body>
</Html>
Operate on an existing Node
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> jquery4 </title>
<Script type = "text/javascript" src = "jquery-1.7.2.js"> </script>
<Script type = "text/javascript">
$ (Function (){
Var li1 = $ ("<li title = 'abc'> hello </li> ");
Var li2 = $ ("<li title = 'abc'> world </li> ");
Var li3 = $ ("<li title = 'abc'> hello world </li> ");
$ ("Ul"). append (li1 );
$ ("Ul"). prepend (li2 );
$ ("Ul li: eq (4)"). after (li3 );
});
</Script>
</Head>
<Body>
<P title = "hello world"> do you think the Shengsi garden training is good? </P>
<Ul>
<Li title = "1"> good </li>
<Li title = "2"> good </li>
<Li title = "3"> excellent </li>
<Li title = "4"> excellent </li>
<Li title = "5"> great </li>
<Li title = "6"> I cannot describe it </li>
</Ul>
</Body>
</Html>