javascript - 使用 jQuery 删除脚本

标签 javascript jquery jquery-plugins jquery-events

我的 jQuery 有问题。所以,我想删除 <div> 中的脚本. 我的 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>

我的 jQuery :

 var stringOfHtml = '<script type="text/javascript" src="http://firstScript.com"></script>';
 var html = $(stringOfHtml);
 html.find('script').remove();

我想删除包含 http://firsttScript.com 的脚本,但没有工作。可以删除此脚本并在之后添加吗?因为我需要刷新这个脚本

最佳答案

您可以将其指定为以下代码:

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

关于javascript - 使用 jQuery 删除脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30072887/

相关文章:

javascript - Angular 表单提交两次

asp.net - Ajax更新面板和Jquery的使用差异:ajax() method

javascript - 有没有可以让我制作漂亮的滚动墙的插件/库?

Twitter 主页中的 jQuery "push down"列表

jQuery 标签或徽章文档

javascript - 对获取的数据使用react

javascript - 如何取消取消所有订阅和异步任务?

javascript - 同时应用两个不同的 CSS 转换

AJAX 调用后 jQuery tablesorter 插件不起作用

javascript - 我可以在不需要 [formGroup] 的情况下使用 [formControl] 吗?