How to add Multiple Pages in Single HTML file Using JavaScript, Multiple HTML Files In One HTML File Using JavaScript
Hi guys today i will tell you through this tutorial that how do you include multiple html files in javascript in only one file?
I will tell you today by step by step through this tutorial, let’s go.
Overview
Step 1:- First, you have to create a html file.You can put its name index.html.
Step 2:- In the second step, you create a file named header.html. We will include this file from the index file.
Step 3:- In the second step, you create a file named footer.html. We will include this file from the index file.
index.html
<!DOCTYPE html> <html> <head> <title>Include Multiple HTML File Into Single HTML File</title> </head> <script src="https://code.jquery.com/jquery-3.3.1.js"></script> <script> $(function(){ $("#header").load("header.php"); $("#footer").load("footer.php"); }); </script> <body> <div id="header"></div> <div id="footer"></div> </body> </html>
header.html
<h1>What is Lorem Ipsum?</h1> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
footer.html
<h2>What is Lorem Ipsum Footer?</h2> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>