且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

本机JavaScript中的jQuery.getScript替代方案

更新时间:2023-01-26 22:32:52

你可以像这样获取脚本: / p>

You can fetch scripts like this:

(function(document, tag) {
    var scriptTag = document.createElement(tag), // create a script tag
        firstScriptTag = document.getElementsByTagName(tag)[0]; // find the first script tag in the document
    scriptTag.src = 'your-script.js'; // set the source of the script to your script
    firstScriptTag.parentNode.insertBefore(scriptTag, firstScriptTag); // append the script to the DOM
}(document, 'script'));