[英]How to match HTML header and footer
我有以下脚本,在其中解析整个HTML并绑定到div(主页):
function htmlResponse() {
var res = "";
debugger;
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
options.async = true;
});
$.ajax({
url: "http://localhost:1469/Home.aspx",
success: function (result) {
res = result;
res = res.replace(/\/CMSPages\/GetResource\.ashx/g, 'http://localhost:1469/CMSPages/GetResource.ashx');
res = res.replace(/\/WebResource\.axd/g, 'http://localhost:1469/WebResource.axd');
res = res.replace('<ul>', '<ul class="fallback browse-experience-drop-down-width">');
$("#homePage").html(res);
}
}).done(function () {
});
};
res
变量包含完整的HTML,需要将其绑定到div主页。
我如何编写另一个仅将<HEADER>
提取到</HEADER>
和<FOOTER>
直到</FOOTER>
正则表达式?
并将这两个部分绑定到两个div标签中?
如下所示:
header = res.regex("REGEX FOR FETCHING HEADER");
footer = res.regex("REGEX FOR FETCHING FOOTER");
$("#HEADER").html(header);
$("#FOOTER").html(footer);
/<HEADER>(\n.*)*<\/HEADER>/g
应该可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.