jQuery 如何使用 HTML 创建母版页?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18464326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a master page using HTML?
提问by Aisha
I have a website which I want to have a consistent style (a header and a side menu) in every page.
我有一个网站,我希望每个页面都具有一致的样式(标题和侧边菜单)。
I want to create something similar to a master page for it. I don't want to use frames.
我想为它创建类似于母版页的内容。我不想使用框架。
How could I achieve this using HTML, CSS, JavaScript and jQuery?
我如何使用 HTML、CSS、JavaScript 和 jQuery 实现这一目标?
回答by Able Alias
you can use jQuery Load function to include header or menu html page, for example, to include a common header html file,
您可以使用 jQuery Load 函数来包含标题或菜单 html 页面,例如,包含一个常见的标题 html 文件,
<div id="new-header">
<script>
$("#new-header").load("header.html");
</script>
</div>