web前端|js教程
动态加载JS
web前端-js教程
直接看实例。
例1 重新加载js文件
柯林程序源码免费版,ubuntu文件输入换行,西安真然爬虫,hooklife php,seo与facebooklzw
function loadJs(file) {
var head = $("head").remove("script[role= eload]");
$("" + "").attr({ role: eload, src: file, type: ext/javascript }).appendTo(head);
}
例2 重新载入javascript文件的方法(给js定个id),自己封装成一个方法方便大家使用:
多管理员社区源码,vscode添加git项目,ubuntu配置双屏,测试tomcat安装失败,地铁爬虫,php union,佛山抖音seo系统,免费的视频模板下载网站哪个好,手机html5单页模板lzw
function reloadAbleJSFn(id,newJS)
{
var oldjs = null;
var t = null;
var oldjs = document.getElementById(id);
if(oldjs) oldjs.parentNode.removeChild(oldjs);
var scriptObj = document.createElement("script");
scriptObj.src = newJS;
scriptObj.type = "text/javascript";
scriptObj.id = id;
document.getElementsByTagName("head")[0].appendChild(scriptObj);
}
例3 jquery的就直接使用getScript就可以了。
asp源码 淘宝数据导入,vscode等宽字体设置,ubuntu装kazam,tomcat读取中文配置,sqlite3 事务锁索引,屋里潮湿出现的小黑爬虫是什么虫,字符串_大写 php,郑州seo线上优化方案,好的分享网站,百变模板快速复原lzw
$(function()
{
$(#loadButton).click(function(){
$.getScript( ew.js,function(){
newFun(\"Checking new script");//这个函数是在new.js里面的,当点击click后运行这个函数
});
});
});