![](/img/trans.png)
[英]Remove <style> tag and <script> tag from plain HTML using Jquery
[英]remove style tag inside html using jquery
我如何刪除html內的樣式標簽
我想刪除其中的完整樣式標簽和CSS,請嘗試以下操作:
html = html.replace(/<br>/g, ' ');
console.log('0='+html);
html2 = html.replace(/<div>/g, ' ');
console.log('1='+html2);
html2 = html2.replace(/ /g, ' ');
html2 = html2.replace(/(<([^>]+)>)/ig,"");
但這只是刪除樣式標簽,而不刪除CSS
您可以使用jQuery .remove()
方法從頁面中刪除所有樣式標簽:
$('html').find('style').remove();
如果HTML在變量( html )中,請使用:
$('style', html).remove();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.