Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to load header and footer using Javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.59k
    Comment on it

    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>
    

    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.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: