【问题标题】:remove style tag inside html using jquery使用jquery删除html中的样式标签
【发布时间】:2014-08-10 07:32:59
【问题描述】:

如何删除 html 中的样式标签

我想删除其中的完整样式标签和 css 我试试这个:

  html = html.replace(/<br>/g, ' ');
        console.log('0='+html);
        html2 = html.replace(/<div>/g, ' ');
        console.log('1='+html2);
        html2 = html2.replace(/&nbsp;/g, ' ');
        html2 = html2.replace(/(<([^>]+)>)/ig,"");

但这只是删除样式标签而不删除 css

【问题讨论】:

标签: javascript jquery html css styles


【解决方案1】:

您可以使用 jQuery .remove() 方法从您的页面中删除任何样式标签:

$('html').find('style').remove();

如果 HTML 在变量中 (html),请使用:

$('style', html).remove();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-08
    • 2014-12-05
    • 1970-01-01
    • 1970-01-01
    • 2012-07-13
    • 1970-01-01
    • 2016-02-22
    相关资源
    最近更新 更多