jquery封装公共的header、footer等组件
- 在 index.html 中先引入 jquery.min.js
- 在index.html 页面中预留公共页面的引入位置:
…
- 写一个公共js,在每个html中引入该js
对于选中当前页面对应的菜单项处理方法,一定要放在公共页面加载完毕之后。
<style>
.footer{
width: 100%;padding: 20px 0;text-align: center;font-size: 16px;background:#FAFAFA;color: #222222
}
</style>
<div class="footer">
<span>嘻嘻嘻嘻嘻嘻嘻</span>
<a href="xxx"
target="_blank">Copyright © 2019 xxx -xxxx</a>
</div>
主页面引入:
<div class="jsc-footer"></div>
<script>
$(function () {
//提公共头部
$(.jsc_top).load(../../public/top.html);
//公共侧导航
$(.jsc_side).load(../../public/side.html);
//公共底部
$(.jsc-footer).load(../../public/footer.html);
});
</script>
