jQuery - move element with javascript inside
I'm using jquery to move a element that contains javascript code inside it, like this:
<li class="a1">
<div class="el">
<script type="text/javascript"> document.write('Hello World'); </script>
...
</div>
</li>
<li class="a2">
</li>
<a class="trigger">link</a>
so I attached a click event on a.trigger that will move div.el into the 2nd 开发者_开发问答list. the problem is that the js inside it makes the browser to open a new window only with div.el inside it :(
Don't use document.write because it will cause headaches. Enhance progressively:
$(".el").html('Hello World');
And it will work just fine.
精彩评论