views:

36

answers:

1

Hi

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 :(

A: 

Don't use document.write because it will cause headaches. Enhance progressively:

$(".el").html('Hello World');

And it will work just fine.

galambalazs