1.topHtml的格式设置如下:
<link rel="stylesheet" href="../topPage/topPage.css" type="text/css" />
<link rel="stylesheet" href="../../css/commen.css" type="text/css" />
<div class="pc-top-fix"></div>
<script src="../../js/jquery-3.4.1/jquery-3.4.1.min.js" type="text/javascript"></script>
<script src="../../js/commen.js" type="text/javascript"></script>
<script type="text/javascript"></script>
2.在需要引用到的页面使用load方法。
$(document).ready(function() {
// 加载顶部
$("#head").load("../topPage/topPage.html");
$("#footer").load("../bottomPage/bottomPage.html");
});
3.注意如果在某些页面需要加载顶部的一些元素,需要在load的success中写入,即元素加载完毕后写入。
$("#head").load("../topPage/topPage.html", function(response, status) {
if (status == "success") {
chooseOneStyle("add-library");
}
});