| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 3 | <head> |
|---|
| 4 | <title>Test</title> |
|---|
| 5 | <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> |
|---|
| 6 | <script type="text/javascript"> |
|---|
| 7 | $(document).ready(function(){ |
|---|
| 8 | $("a.clone").click(function () { |
|---|
| 9 | $("#test_clone_2").empty().append($("#test_clone").clone(true).children()); |
|---|
| 10 | }); |
|---|
| 11 | |
|---|
| 12 | $("a.clone_fix").click(function () { |
|---|
| 13 | $('#test_clone textarea').each(function() { |
|---|
| 14 | $(this).text($(this).val()); |
|---|
| 15 | }); |
|---|
| 16 | |
|---|
| 17 | $("#test_clone_2").empty().append($("#test_clone").clone().children()); |
|---|
| 18 | }); |
|---|
| 19 | }); |
|---|
| 20 | </script> |
|---|
| 21 | </head> |
|---|
| 22 | <body> |
|---|
| 23 | <p> |
|---|
| 24 | <span id="test_clone"> |
|---|
| 25 | <input type="text" name="test_inp" /> |
|---|
| 26 | <br /> |
|---|
| 27 | <textarea name="test_text" rows="10" cols="20"></textarea> |
|---|
| 28 | </span> |
|---|
| 29 | |
|---|
| 30 | <hr /> |
|---|
| 31 | |
|---|
| 32 | <a href="#" class="clone">clone</a> | <a href="#" class="clone_fix">clone fixed</a> |
|---|
| 33 | |
|---|
| 34 | <hr /> |
|---|
| 35 | |
|---|
| 36 | <span id="test_clone_2"> |
|---|
| 37 | |
|---|
| 38 | </span> |
|---|
| 39 | </p> |
|---|
| 40 | </body> |
|---|
| 41 | </html> |
|---|