0

Have any advice. Why I can not add the javascript into a DOM?

var strScript = "<script type='text/javascript'></script>";
$("#someElement").append(strScript);
Bunlong
  • 652
  • 1
  • 9
  • 21
  • It doesn't do much, but that works just fine in my browser (using `body` instead of `#someElement`). – sczizzo Jun 14 '12 at 16:35
  • Why are you trying to append a script tag into the DOM instead of simply calling a function when you want something to be executed? – Ben Roux Jun 14 '12 at 16:36
  • 1
    possible duplicate of [jQuery: Can't append – j08691 Jun 14 '12 at 16:37
  • ok. Thank all. now I have found the answer... Cheer !!! – Bunlong Jun 14 '12 at 16:43

2 Answers2

1

See this post. The top-rated comment does a stand-up job of going through what works and why.

Community
  • 1
  • 1
Ross
  • 2,448
  • 1
  • 21
  • 24
0

You can always do

document.write('\x3Cscript src="your-jsfile.js" type="text/javascript" >\x3C/script>');
MJC
  • 3,871
  • 4
  • 23
  • 34