I'm trying to dynamically add a script to my project using jQuery. The script is successfully added to the head tag but the content is not rendered in the body tag.
This is my code:
<script type="text/javascript">
window.onload = function() {
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "https://form.jotform.com/jsform/81003857231348";
$("head").append(s);
}
</script>
However the script loads successfully if I add it directly:
<script type="text/javascript" src="https://form.jotform.com/jsform/81003857231348"></script>
https://jsfiddle.net/xpvt214o/98587/
Am I missing something?
getScript()type="text/javascript"