IT源码网

怎样获取所有style节点

xmjava 2021年03月09日 编程语言 440 0

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

document.styleSheets instanceof StyleSheetList; 
// true

 

注意: 

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

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

评论关闭
IT源码网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!