【发布时间】:2015-07-16 08:42:12
【问题描述】:
我的 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 的脚本女巫,但无法正常工作。可以删除此脚本并在之后添加吗?因为我需要刷新这个脚本
【问题讨论】:
-
<script>是否存在于您的实际 html 中?还是只是一个变量? -
更好的解决方案:
$('#right-bloc').find('script[src="http://firstScript.com"]').remove().
标签: javascript jquery jquery-plugins jquery-events