Create <script> element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Script

Description

Create <script> element

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>JS</title> 
   </head> 
   <body> 
      <script type="text/javascript">
            var/*from w ww .  j a  v a  2  s .c o  m*/
                scriptElement,
                script;
            scriptElement = document.createElement('script');
            scriptElement.src = "https://code.jquery.com/jquery-2.2.2.min.js";
            script = document.getElementsByTagName('script')[0];
            script.parentNode.insertBefore(scriptElement, script);
        
      </script>  
   </body>
</html>

Related Tutorials