/**
* 重新加載下js文件
* @param id
* @param newJS
* @returns {boolean}
*/
function reloadAbleJSFn(id, newJS = false)
{
var oldJs = jQuery('#' + id);
// 沒找返回下
if (oldJs.length < 1)
return false;
// 未傳輸新的js路徑 就用舊的
if (!newJS)
newJS = jQuery(oldJs).attr('src');
var parent = jQuery(oldJs).parent();
jQuery(parent).find('#' + id).remove();
var scriptObj = document.createElement("script");
scriptObj.src = newJS;
scriptObj.type = "text/javascript";
scriptObj.id = id;
jQuery(parent).append(scriptObj);
}
參考:https://blog.csdn.net/wudean0910/article/details/84980979
代碼已經過修改。。。不知算原創嗎。
有前端問題的童鞋歡迎加羣討論:
115658205