| 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.js"></script>
|
|---|
| 9 | <script type="text/javascript">
|
|---|
| 10 | var html1 = "<a href='#'>hello #1</a><scr" + "ipt>$(function () { alert('I will execute');" +
|
|---|
| 11 | "$('a').click(function () { alert('hi'); return false; });" +
|
|---|
| 12 | "});</scr" + "ipt>";
|
|---|
| 13 | var html2 = "<div><a href='#'>hello #2</a><scr" + "ipt>$(function () { alert('I will execute');" +
|
|---|
| 14 | "$('a').click(function () { alert('hi, but you won\\'t see me'); return false; });" +
|
|---|
| 15 | "});</scr" + "ipt></div>";
|
|---|
| 16 | $(function () {
|
|---|
| 17 | $("button:first").click(function () {
|
|---|
| 18 | $("#adiv").text(html1);
|
|---|
| 19 | $("#container").html(html1);
|
|---|
| 20 | });
|
|---|
| 21 | $("button:last").click(function () {
|
|---|
| 22 | $("#adiv").text(html2);
|
|---|
| 23 | $("#container").html(html2);
|
|---|
| 24 | });
|
|---|
| 25 | });
|
|---|
| 26 | </script>
|
|---|
| 27 | </head>
|
|---|
| 28 | <body>
|
|---|
| 29 | <button>Load outside parent</button>
|
|---|
| 30 | <button>Load inside parent</button>
|
|---|
| 31 | <div id="container">
|
|---|
| 32 | Hi
|
|---|
| 33 | </div>
|
|---|
| 34 | <div id="adiv"></div>
|
|---|
| 35 | </body>
|
|---|
| 36 | </html>
|
|---|