[英]insert one page content to the another page in html
<script src="jquery.js"></script> <header id="menu-header"> //menu bar </header> <script> $(function(){ $("#menu-header").load("header.html"); }); </script>
Here I want to include my header menu into different html pages. 在这里,我想将标题菜单包含到不同的html页面中。 How to include one html header into each page?
如何在每个页面中包含一个html标头? I have already used jQuery
load
function but it is not working in Chrome. 我已经使用了jQuery
load
功能,但是在Chrome中无法正常工作。
//menu bar //菜单栏
You can do using jQuery
Get Request. 您可以使用
jQuery
Get Request做。
For example here is menu.html
file 例如,这里是
menu.html
文件
<ul>
<li><a href="www.naveedramzan.com" title="Home">Home</a>
<li><a href="www.naveedramzan.com/about-naveed" title="About">About</a>
</ul>
Here is index.html
file 这是
index.html
文件
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div id="menu"></div>
<script>
$(document).ready(function(){
$.get( "menu.html", function( data ) {
$( "#menu" ).html( data );
});
});
</script>
jQuery will load menu.html file and add html in #menu
and that you can do on all pages jQuery将加载menu.html文件并在
#menu
添加html,并且您可以在所有页面上执行此操作
This node.js library will help you; 这个node.js库将为您提供帮助; templatesjs ;
templatejs ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.