首页 > 技术文章 > 怎样获取所有style节点

aisowe 2019-09-17 18:18 原文

通过 document.styleSheets 获取所有的样式表节点.

document.styleSheets instanceof StyleSheetList;
// true

 

注意: 

1. 返回的是一个StyleSheetList对象实例;

2. 不能通过document.querySelectorAll('style') 和 document.getElementsByTagName('style') 获取.

推荐阅读