Bunlong
Bunlong

Reputation: 662

Add Javascript into a DOM

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

var strScript = "<script type='text/javascript'></script>";
$("#someElement").append(strScript);

Upvotes: 0

Views: 862

Answers (2)

MJC
MJC

Reputation: 3939

You can always do

document.write('\x3Cscript src="your-jsfile.js" type="text/javascript" >\x3C/script>');

Upvotes: 0

Ross
Ross

Reputation: 2468

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

Upvotes: 1

Related Questions