您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

使页眉和页脚文件包含在多个html页面中

使页眉和页脚文件包含在多个html页面中

您可以使用jquery完成此操作。

将此代码放在 index.html

<html>
<head>
<title></title>
<script
    src="https://code.jquery.com/jquery-3.3.1.js"
    integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
    crossorigin="anonymous">
</script>
<script> 
$(function(){
  $("#header").load("header.html"); 
  $("#footer").load("footer.html"); 
});
</script> 
</head>
<body>
<div id="header"></div>
<!--Remaining section-->
<div id="footer"></div>
</body>
</html>

并将此代码放在header.html和中footer.html,与index.html

<a href="http://www.google.com">click here for google</a>

现在,当您访问时index.html,您应该可以单击链接标记

其他 2022/1/1 18:14:18 有661人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶