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>

  • 相关阅读:
    cpio命令
    INI文件格式
    ubuntu死机怎么办
    vim中执行shell命令
    android安装busybox
    putty远程连接ubuntu
    java sdk与jdk区别
    一些使用JSP 编程技巧(转)
    ubuntu12.04 下安装 jdk1.7 maven3.1
    Java Web进阶步骤
  • 原文地址:https://www.cnblogs.com/6531792-j/p/10768639.html
Copyright © 2011-2022 走看看