本文介紹了使用 jQuery 刪除腳本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我的 jQuery 有問題.所以,我想刪除 <div>
中的腳本.我的 html 是:
I have a problem with my jQuery. So, I want to remove a script who is inside a <div>
.
My html is :
<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 :
My jQuery :
var stringOfHtml = '<script type="text/javascript" src="http://firstScript.com"></script>';
var html = $(stringOfHtml);
html.find('script').remove();
我想刪除包含 http://firsttScript.com
的腳本,但無法正常工作.可以刪除此腳本并在之后添加嗎?因為我需要刷新這個腳本
I want to remove the script witch contains http://firsttScript.com
, but not working. It's possible to remove this script and add after? Because I need to refresh this script
推薦答案
可以指定為如下代碼:
html.find('script[src="http://firstScript.com"]').remove();
這篇關于使用 jQuery 刪除腳本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!