html动态添加公共页头和页脚

//js部分:
<script>
  $(function(){
    $(document).ready(function(){
    //jquery load方法加载公共头部
        $("#footer").load("footer.html");
    });
  })
</script>
//在需要引用的页面中加添id为footer的节点即可

<div id="footer"></div>
//footer.html 不需要多余的<head>节点,直接dom就行

 <footer class="cpy-right bg-theme ">
        <h1>
         我是公共页脚 
        </h1>     
 </footer>
  

  

原文地址:https://www.cnblogs.com/Lucyy/p/14001110.html