我想知道如何通过 JavaScript 获取 HTMLElement 的相应样式表对象。由于此逻辑在每个浏览器的 Inspector-Tools 中都以某种方式实现,因此它也应该可以在页面内实现 - 我希望如此。
必须有类似的东西
var cssStyleDeklaration = window.getComputedStyle($0);
var cssRule = cssStyleDeklaration.color;
console.log(cssRule.parentStyleSheet.href);
->> http://the.style.sheet/source.css
我阅读了所有关于 CSSOM-API 的文档,但没有找到任何方法。