$(function () { var loadHtmlArr = [ // "cover", // "preface", // "section_1", "section_2", // "section_3", // "section_4", ]; $(".pdf_root").html(loadHtmlArr.map(function (htmlName) { return "
"; }).join("")); loadHtmlArr.forEach(function (htmlName) { if (htmlName === "preface") { $("." + htmlName + "_html_root").data("page-params", JSON.stringify({ htmlName: htmlName, subjectname: "语文", num: 12 })); } else if (htmlName === "section_1") { $("." + htmlName + "_html_root").data("page-params", JSON.stringify({ htmlName: htmlName, subjectname: "数学", num: 33 })); } console.log(htmlName); $("." + htmlName + "_html_root").load("../sections/" + htmlName + ".html"); }); });