我使用jquery.load()
方法将页眉和页脚调用到不同的页面中。但在加载页面时,页脚和页眉有延迟。那是当我运行这个“我的内容..”之后,仅显示标题。我想同时显示页眉、内容、页脚加载。你能帮我一下吗?
<html>
<head>
<script>
$(document).ready(function() {
$("#header").load("header.html");
$("#footer").load("footer.html");
});
</script>
</head>
<body>
<div id="header"></div>
<div id="content">My content comes here...</div>
<div id="footer"></div>
</body>
</html>
最佳答案
它不适用于 Google Chrome(本地), 因此,如果您想运行此文件,您可以使用FireFox,否则它将在服务器上运行。
添加Jquery CDN
美好的一天!
<script type="text/javascript">
$(document).ready(function(){
$("#header").load("header.html");
$("#footer").load("footer.html");
});
</script>
</head>
<body>
<div id="header"></div>
<div id="content">My content comes here...
</div>
<div id="footer"></div>
</body>
关于jquery - 如何使用 jquery.load() 在内容之前加载页眉和页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25283554/