| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|---|
| 2 | <html> |
|---|
| 3 | <head> |
|---|
| 4 | <title>Tester</title> |
|---|
| 5 | <style type="text/css"> |
|---|
| 6 | #container { background:yellow; width:200px; } |
|---|
| 7 | </style> |
|---|
| 8 | <script type="text/javascript" src="../jquery.test.js"></script> |
|---|
| 9 | <script type="text/javascript"> |
|---|
| 10 | function doIt() { |
|---|
| 11 | $("<b></b>").appendTo("form").append($("input")); |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | function doIt2() { |
|---|
| 15 | $("<b></b>").appendTo("form").get(0).appendChild($("input").get(0)); |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | $(function () { |
|---|
| 19 | $("#doit").click(doIt); |
|---|
| 20 | $("#doit2").click(doIt2); |
|---|
| 21 | }); |
|---|
| 22 | </script> |
|---|
| 23 | </head> |
|---|
| 24 | <body> |
|---|
| 25 | <button id="doit">jQuery append</button> |
|---|
| 26 | <button id="doit2">DOM appendChild</button> |
|---|
| 27 | <div id="container"> |
|---|
| 28 | Hi |
|---|
| 29 | </div> |
|---|
| 30 | <form> |
|---|
| 31 | <input type="checkbox" name="a" /> |
|---|
| 32 | </form> |
|---|
| 33 | <div id="adiv"></div> |
|---|
| 34 | </body> |
|---|
| 35 | </html> |
|---|