over 9 years ago
Hello Reader's. If you have developed the header and footer of the website separatly then it's very easy to make them render on a webpage. By using the JS you can call them with a single line of code as written below:-
- <html>
- <head>
- <title></title>
- <script src="//code.jquery.com/jquery-1.10.2.js"></script>
- <script>
- $(function(){
- $("#header").load("header.php"); //set the path to your header file
- $("#footer").load("footer.php"); // set the path to your footer file
- });
- </script>
- </head>
- <body>
- <div id="header"></div>
- <div id="footer"></div>
- </body>
- </html>
<html> <head> <title></title> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script> $(function(){ $("#header").load("header.php"); //set the path to your header file $("#footer").load("footer.php"); // set the path to your footer file }); </script> </head> <body> <div id="header"></div> <div id="footer"></div> </body> </html>
You just have to call the jquery code and give paths to you header and footer files. Div with the 'header' will include the data of header and same as footer also.
Can you help out the community by solving one of the following Javascript problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)