简体   繁体   中英

remove style tag inside html using jquery

how can i remove style tag inside html

i want remove complete style tag and css inside it i try this:

  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,"");

but this just remove style tag and don't remove css

我的风格代码

You can use the jQuery .remove() method to remove any style tags from your page :

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

If the HTML is in a variable ( html ), use:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM