Any idea why the piece of code below does not add the script element to the DOM?
var code = \"\";
$(\"#someElement\").append(cod
Another way you can do it if you want to append code is using the document.createElement
method but then using .innerHTML
instead of .src
.
var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.innerHTML = 'alert("Hey there... you just appended this script to the body");';
$("body").append( script );