且构网

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

如何在另一个正在编写的jQuery插件中包含一个外部插件

更新时间:2023-11-20 22:44:10

当然 - 你可以创建一个新脚本元素并将其附加到头部。

var script = document.createElement('script');
script.src = 'url-to-plugin';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);

如果这不起作用,可以尝试此页面,使用 setAttribute 的方法略有不同。

If this doesn't work, maybe try the method on this page, it's a slightly different approach using setAttribute.