如何从DOM中删除以前的js文件

时间:2017-01-10 05:50:07

标签: javascript dom html-head

(function() {

    setTimeout(function(){
        $('#core-notify').remove();
        $('#yourDynamicGeneratedScript').remove();
        $('#yourDynamicGeneratedScriptHtml').remove();

    context = $("#context").val();
        lid =  $("#userid").val();
        tid = $("#tenentId").val();
        dp_url = $("#dpUrl").val();

    var script_tag = document.createElement('script');
    script_tag.setAttribute("type","text/javascript");
    script_tag.setAttribute('id', 'yourDynamicGeneratedScript');

    script_tag.setAttribute("src",
    "https://sa.nlpbots.com/lightbot/js/light_bot.js");
      (document.getElementsByTagName("head")[0]).appendChild(script_tag);

    console.log((document.getElementsByTagName("head")[0]));

    },1000);
})(); 

此代码按标记ID删除脚本,但只删除 head 标记,而不是DOM文件。

0 个答案:

没有答案