在HTML页面中加载js文件和css文件的方法

1.在HTML页面加载js文件的方法:

function loadScriptFile(filePath){
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = filePath;
    document.head.appendChild(script);
}

2.在HTML页面加载css文件的方法:

function loadCsstFile(filePath){
    var link = document.createElement("link");
    link.type = "text/css";
    link.rel = "stylesheet";
    link.href = "filePath";
    document.head.appendChild(link);
    //document.getElementsByTagName("head")[0].appendChild(link);
}
原文地址:https://www.cnblogs.com/dcncy/p/8321645.html