simplest way to remove all the styles in a page

后端 未结 4 1544
礼貌的吻别
礼貌的吻别 2020-12-05 03:36

I need to remove all the style definitions in a page using javascript, to obtain the same result as doing View > Page Style > No Style in Firefox. Which i

4条回答
  •  无人及你
    2020-12-05 04:01

    Actually, document.querySelectorAll returns NodeList which has forEach method.

    document.querySelectorAll('link[rel="stylesheet"], style')
      .forEach(elem => elem.parentNode.removeChild(elem));
    

提交回复
热议问题