// Create the element
var script = document.createElement("script");
// Add script content
script.innerHTML = "...";
// Append
document.head.appendChild(script);
Or
document.body.appendChild(script);
More Related Contents:
- jQuery append() vs appendChild()
- jQuery DOM changes not appearing in view source
- .append(), prepend(), .after() and .before()
- How to appendChild(element) many times. (The same element)
- Add / Change parameter of URL and redirect to the new URL
- How can I upload files asynchronously with jQuery?
- Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?
- How do I detect a click outside an element?
- Stop form refreshing page on submit
- Variable doesn’t get returned from AJAX function
- Only detect click event on pseudo-element
- Force Download an Image Using Javascript
- detecting line-breaks with jQuery?
- Very Simple, Very Smooth, JavaScript Marquee
- How to create a stopwatch using JavaScript?
- How to show a spinner while loading an image via JavaScript
- Change color of specific words in textarea
- Why can’t we have return in the ternary operator?
- Is it any limit for POST data size in Ajax?
- How to generate a thumbnail image after adding an image inside an input type=”file” in a form and submitting them both on the same form
- Can you have a JavaScript hook trigger after a DOM element’s style object changes?
- Get image preview before uploading in React
- How do I select the innermost element?
- Send form data using ajax
- Automatically scroll down chat div
- Running javascript after page is fully rendered
- How to return an array from an AJAX call?
- How to bind both Mousedown and Touchstart, but not respond to both? Android, JQuery
- Find and replace nth occurrence of [bracketed] expression in string
- JQuery Modal Boxes and Iframe