假设我有这个字符串:
let string = '<h1 style="lots of class"> </h1><h2> <p style="bunch of class"> </p> <p style="bunch of class"> </p></h2>';
所以基本上它是一堆这样的元素,但在字符串中:
<h1 style="bunch of class"> </h1>
<h2>
<p style="bunch of class"> </p>
<p style="bunch of class"> </p>
</h2>
使用 jquery 或 vanilla javascript,如何从字符串中删除样式属性?
我已经尝试过这个:
$(string).find('h1').removeAttr('style');
但它不工作