Tips for creating dynamic Dom_javascript Based on JavaScript

Source: Internet
Author: User
This article describes how to create a dynamic Dom Based on JavaScript. For more information, see Dynamic script

We can use the script element on the page to insert javascript code into the page. There are two ways: one is to reference external JS files through the src attribute, and the other is to use this element to contain a piece of js Code. The so-called dynamic script means that the script does not exist when the page is loaded. In the future, you can modify the DOM to dynamically Add the script. Like html elements, dynamic scripts can be created in two ways: inserting external files and directly inserting JavaScript code.

The dynamically loaded external JavaScript code can be executed immediately, for example, the following code:

var script = document.createElement("script");script.type = "text/javascript";script.src = "demo.js?1.1.11";document.body.appendChild(script);

The above code is displayed inElement generates a script node:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.