HTML code with JS to achieve reuse

Source: Internet
Author: User

As a front-end developer, everyone will encounter a problem is repeated code how to deal with, if always copy and paste, will make the code is very large, difficult to read. While some languages, such as node. js, can be managed in a modular format, using JS or jquery can be a simple and time-consuming setup for other environments.

If there is a piece of HTML code that I need to use on multiple pages, let's implement the following:

<! Doctype html>    

In fact, the code is simple; we did a few things:

1, first save a variable A;

2, we need JS splicing out our HTML code, and assign it as a variable to A;

3, with a for loop to achieve multiple references;


This article is from the "10975329" blog, please be sure to keep this source http://10985329.blog.51cto.com/10975329/1889286

HTML code with JS to achieve reuse

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.