zoukankan      html  css  js  c++  java
  • 多个页面引用公共的头部 header.html 和尾部 footer.html

    方法:通过load()函数,引入公共头部和尾部文件; 
    js代码预览: 
    $(".headerPage").load("header.html"); 
    $(".footerPage").load("footer.html");

    步骤:

       1. 把头部代码和尾部代码分别单独写到一个新的html页面(头部header.html  尾部footer.html),以便引用;

       2. 在index.html页面  把放头部的地方  写<div class="headerPage"></div>  (存一个div空间);

                                        把放尾部的地方  写<div class="footerPage"></div>  (存一个div空间);

       3. 在index.html页面,引入js

                                       <script src="js/jquery-3.3.1.js" type="text/javascript" charset="utf-8"></script>

                                        再写js代码(只要是公共部分就可以引用)

                                      <script type="text/javascript">

                                         $(".headerPage").load("header.html");

                                         $(".footerPage").load("footer.html");

                                     </script>

  • 相关阅读:
    原生js 实现 map
    前端安全学习
    前端性能优化
    前端的跨域请求方法使用场景及各自的局限性
    7-7 12-24小时制(15 分)
    7-4 BCD解密(10 分)
    7-2 然后是几点(15 分)
    厘米换算英尺英寸
    鸡兔同笼
    数组:经典计数
  • 原文地址:https://www.cnblogs.com/6531792-j/p/10768639.html
Copyright © 2011-2022 走看看