功能3 -- 基於jquery的load()實現多個.html靜態頁,引用同一個header.html和footer.html文件

<!DOCTYPE html><html><head><meta charset='utf-8'><title>引入html</title></head>

<body>

<!-- 引進的頭部 -->
<header class="header"></header>


<!-- 每一個頁面的主代碼 --> 
<p>···代碼省略···</p>

<!-- 引入的尾部 -->  
<footer class="footer"></footer>

<script src="js/jquery.min.js"></script>
<script>
    $(function(){
        $(".header").load("header.html");
        $(".footer").load("footer.html");
    });
</script>
</body>
</html>

 

<!-- header.html頁面 -->
<nav>
  <ul>
    <li>首頁</li>
    <li>其餘</li>   
  </ul>
</nav>

 

<!-- footer.html頁面 -->
<div>
  <p>Copyright ©2018-2019 || 魯ICP備17036706號</p>
<div>

 

 

源自:http://www.javashuo.com/article/p-ongfoebx-e.htmlhtml

相關文章
相關標籤/搜索