【问题标题】:How to Remove a script with jQuery如何使用 jQuery 删除脚本
【发布时间】:2021-04-12 20:28:07
【问题描述】:

我的 jQuery 有问题。所以,我想删除一个在 .我的 html 是:

<div id="right-bloc">
        <div class="right-bloc-pub-1">
            <script type="text/javascript" src="http://firstScript.com"></script>
        </div>
        <div class="right-bloc-pub-2">
            <script type="text/javascript" src="http://secondScript.com"></script>
        </div>
</div>

我找到了下面的解决方案

html.find('script[src="http://firstScript.com"]').remove();

但问题是它只删除了只有 HTTP URL 的脚本,因为有些脚本有那种 URL

//ialtears.com/d2/32/42/d23949fadf7b59629f8345.js

我想删除那种网址

【问题讨论】:

    标签: javascript jquery iframe


    【解决方案1】:

    你可以这样试试:

    JQuery(document).ready(function($){
        $('script').each(function() {
              this.parentNode.removeChild(this);
        });
    });

    【讨论】:

      猜你喜欢
      • 2015-07-16
      • 1970-01-01
      • 1970-01-01
      • 2020-09-01
      • 2011-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多