久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

是否有任何 jquery 插件可以在 HTML 頁面中保留常見

Is there any jquery plugin to keep common header and footer in a HTML page?(是否有任何 jquery 插件可以在 HTML 頁面中保留常見的頁眉和頁腳?)
本文介紹了是否有任何 jquery 插件可以在 HTML 頁面中保留常見的頁眉和頁腳?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

是否有任何 jquery 插件可用于在 HTML 頁面中保留公共頁眉和頁腳?

Is there any jquery pluginto use to keep common header and footer in a HTML page?

如果我可以將 header.html 和 footer.html 添加到 index.html 中.

Like if i can add header.html and footer.html into index.html.

我知道我可以使用 php,但如果可能的話,我不想在本地 PC 上安裝任何服務器.稍后完成所有工作后,我將使用 php 包含

I know I can with php but if possible I want to do without installing any server on my local PC. later after all work done i will use php includes

header.html

<title>Template</title>
<meta name="description" content="">
<link rel="stylesheet" href="css/styles.css?v=1.0">
<script src="js/modernizr-2.0.6.min.js"></script>

index.html

{include header.html}

<body class="home">

{include footer.html}

Footer.html

<footer class="f1">
    <p>copyright &copy; year</p>
</footer><!-- .f1 -->

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="js/general.js"></script>
</body>
</html>

推薦答案

jQuery 本身有一些特性可以讓你做到這一點.如果您可以在每個頁面上選擇頁眉/頁腳的容器,您可以插入任何您想要的通用內(nèi)容,甚至替換現(xiàn)有的內(nèi)容.

jQuery itself has some features that allow you to do that. If you can select header's/footer's container on each page, you can insert any common content you want, even replace the existing one.

你可以這樣做:

jQuery(function(){
    jQuery('.header').html('SOME COMMON HEADER');
    jQuery('.footer').html('SOME COMMON FOOTER');
});

在此處查看實際操作:http://jsfiddle.net/6sCfm/

或者,如果你堅持加載外部文件,你可以這樣做(使用 .load()):

Or, if you insist on loading external files, you can do this (using .load()):

jQuery(function(){
    jQuery('.header').load('header.html');
    jQuery('.footer').load('footer.html');
});

但請注意您作為參數(shù)提供的正確路徑,并確保 文件應該只有您需要的 HTML(沒有 <head><body> 標簽等 - 它會使 HTML 不正確).

but pay attention to correct paths you are giving as parameters and make sure, that files should have only the HTML you need (no <head>, <body> tags, etc. - it will make HTML incorrect).

如果您有整個頁面(使用 <head><header> 等),則只能加載其中的一部分.最好為您要加載的部分(例如 headerfooter)提供有意義的 ID,并在路徑中提供它們作為選擇器:

If you have whole pages (with <head>, <header> etc.), you can load only parts of them. Preferably give meaningful IDs to the parts you want to load (eg. header and footer) and supply them in the path, after space, as selector:

jQuery(function(){
    jQuery('.header').load('header.html #header');
    jQuery('.footer').load('footer.html #footer');
});

這應該足夠靈活:)

這篇關于是否有任何 jquery 插件可以在 HTML 頁面中保留常見的頁眉和頁腳?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創(chuàng)建頭像的 jQuery/JavaScript 庫?)
How to do following mask input problem?(如何做以下掩碼輸入問題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進行單元測試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網(wǎng)站配置偏移量/對齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當文本框獲得焦點時選擇所有內(nèi)容)
主站蜘蛛池模板: 日韩视频一区二区三区 | 国产精品一级 | av在线播放网站 | 日本激情视频中文字幕 | 精品少妇v888av | 国久久| 久久9久 | 欧美国产大片 | 99精品欧美一区二区三区综合在线 | 欧美一区免费 | 国产精品成人一区二区三区 | 97人人超碰 | 懂色中文一区二区三区在线视频 | 看av在线| www.日韩系列 | 999久久久国产精品 欧美成人h版在线观看 | 亚洲国产精品一区 | 国产一区精品在线 | 一区视频在线 | 在线黄色网| 欧美群妇大交群中文字幕 | 欧美高清一级片 | 午夜视频在线 | 一级黄色毛片免费 | 国产成人av在线播放 | 一区二区在线不卡 | 九九综合九九 | 欧美大片一区二区 | 日韩中文在线 | 区一区二在线观看 | 中文字幕在线一区二区三区 | 91精品国产一区二区三区 | 影音先锋欧美资源 | 亚洲一区在线日韩在线深爱 | 成人免费视频网站在线观看 | 久久婷婷香蕉热狠狠综合 | 日韩免 | 日韩精品中文字幕在线 | 日韩一区二区三区在线 | 精品一区二区三区免费视频 | 久久精选 |